读取sd卡里的txt文档信息

File f=null;
    f= new File("/mnt/sdcard/wareh1.txt");//这是对应文件名
    InputStream in = null;
    try {
     in = new BufferedInputStream(new FileInputStream(f));
    } catch (FileNotFoundException e3) {
     // TODO Auto-generated catch block
     e3.printStackTrace();
    }
    BufferedReader br = null;
    try {
     br = new BufferedReader(new InputStreamReader(in, "gb2312"));
    } catch (UnsupportedEncodingException e1) {
     // TODO Auto-generated catch block
     e1.printStackTrace();
    }
    String tmp;

    try {
     while((tmp=br.readLine())!=null){
      //在这对tmp操作
      System.out.println("tmp--->"+tmp);  
    }
     br.close();
     in.close();
    } catch (IOException e) {
     // TODO Auto-generated catch block
   e.printStackTrace();

    }

posted @ 2012-12-11 22:01  水——云——间  阅读(320)  评论(0编辑  收藏  举报