2019-09-17 java按行读取文件 本文记录java按行读取文件的方式。 FileReader+BufferedReader123456789101112private List<String> getFromFile(String path) throws Exception { FileReader reader = new FileReader(path); BufferedReader br = new BufferedReader(reader); List<String> data = new ArrayList<>(10); String line; while ((line = br.readLine()) != null) { data.add(line); } br.close(); reader.close(); return data;} Newer 2019-38-周报 Older Java实现有界优先队列