/** * 按流读取文件 * @param path * @return * @throws FileNotFoundException */ public static BufferedReader openFile(final String path) throws FileNotFoundException { FileInputStream in = new FileInputStream(new File(path)); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); return reader; }
一行一行的读取:
read.readLines();
注意:这里返回的不是数组,而是字符串。
时间: 2024-10-05 04:27:55