使用java输入输出流将c盘根目录下的gource.dat文件的内容按行读出

如题所述

第1个回答  2015-12-10
public static List<String> readFile(String path){
  File f = new File(path);
  BufferedReader br = null;
  List<String> list = new ArrayList<String>();
     try {
   br = new BufferedReader(new FileReader(f));
   String content = null;
   while (true) {
    content = br.readLine();
    if(content == null){
     break;
    }
    list.add(content);
   }
   
  } catch (Exception e) {
   // TODO: handle exception
  }
     return list;
 }

本回答被网友采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网