我在处理文件的最后一行时遇到问题。
java.io.IOException:输入/输出错误
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:272)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.readLine(BufferedReader.java:317)
at java.io.BufferedReader.readLine(BufferedReader.java:382)
一切正常,但在读取最后一行时会在br.readLine()处出错。
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file))) ;
String line = null;
while((line = br.readLine()) != null){}