📌  相关文章
📜  从文件中读取行java代码示例

📅  最后修改于: 2022-03-11 14:52:05.591000             🧑  作者: Mango

代码示例1
private ArrayList readFileLines(String filepath) throws FileNotFoundException, IOException{
  File fp = new File(filepath);
  FileReader fr = new FileReader(fp);
  BufferedReader br = new BufferedReader(fr);

  ArrayList lines = new ArrayList<>();
  String line;
  while((line = br.readLine()) != null) { lines.add(line); }

  fr.close();
  return lines;
}