Java FileInputStream ObjectInputStream 到达文件 EOF 的末尾
2022-09-01 18:21:10
我正在尝试使用readObject读取二进制文件中的行数,但我得到IOException EOF。我这样做的方式是否正确?
FileInputStream istream = new FileInputStream(fileName);
ObjectInputStream ois = new ObjectInputStream(istream);
/** calculate number of items **/
int line_count = 0;
while( (String)ois.readObject() != null){
line_count++;
}