FileReader fileReader = null;
try {
fileReader = new FileReader(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Scanner sc = new Scanner(fileReader);
String line = null;
while((sc.hasNextLine()&&(line=sc.nextLine())!=null)){
if(!sc.hasNextLine()){
System.out.println(line);
}
}
sc.close();
java读取文件最后一行的方法
最新推荐文章于 2022-04-02 17:15:21 发布