문제

I am reading from a .dat file with an unknown amount of objects within it. What I want to do is loop through the file by using the .readObject() method. Is there a way I can determine the amount of times to read the file similar to the way the .hasNext() method works for Scanner?

For example, I would normally use a while loop with hasNext() as a parameter.

while (scFile.hasNext()){ 
   x = scFile.nextInt();
}

Thanks in advance.

도움이 되었습니까?

해결책

Just read the stream until EOFException is thrown. The method you are looking for does not exist.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top