B&S: I have some question about EOFException
posted 11 years ago
I don't think this exception should ever be thrown. When counting the records, you should make sure not to read past the end of the file by using file.getFilePointer() and file.length(). After you know the number of records, there will be no need to read past the end of the file. If you take these precautions and still get an EOFException, then you know something crazy is going on and you should maybe think about closing the app(after notifying the user). In my case, I throw a FatalException if an IOException is caught here(which also catches EOF) because all IOExceptions are bad news.