LarryDpk
发布于 2020-08-16 / 1885 阅读
0

Java从BufferedReader一行一行读取数据

经常需要从BufferedReader读取数据,比如读取csv文件,就要装到BufferedReader里然后一行一行处理。

方法一:

BufferedReader buffered = new BufferedReader(reader);
String line;
while ((line = buffered.readLine()) != null) {
  System.out.println(line);
}

方法二:

BufferedReader buffered = new BufferedReader(reader);
Stream<String> lines = buffered.lines();