Java中使用BufferedReader的readLine()方法读取文件内容
String filePath = "C:\\Users\\91911\\Desktop\\test.txt";//文件路径
File file = new File(filePath);
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8"));//获取字符流
String line;
while((line = reader.readLine()) != null){
System.out.println(line);//循环的到的数据
}
}catch(Exception e){}
finally{
if(reader != null){
try{
reader.close();
}catch(Exception e1){
}
}
}
了解更多
https://blog.csdn.net/GuangRong1/article/details/88764539