(每日一练java)按行读取文件
作者:互联网
FileRead
以下 FileRead
程序中,是按行读取文件的是:
import java.io.*;
public class FileRead {
public static void main(String[] args) throws IOException {
String filePath = "test.txt";
File file = new File(filePath);
BufferedReader reader = new BufferedReader(new FileReader(file));
String lineString = null;
while ((lineString = reader.readLine()) != null) {
System.out.println(lineString);
}
reader.close();
}
}
标签:一练,FileRead,java,String,按行,file,reader,new,lineString 来源: https://blog.csdn.net/dwf1354046363/article/details/122737337