EOFException when reading QueueFile tape

The EOFException shows that End Of File has been reached, that is, there are no more bytes to read. This exception is just another way to signal that there is nothing more to read, whereas other methods return a value, like -1. As you can see in your error stack trace, the methods throwing the exception are read methods; java.io.RandomAccessFile.readFully(RandomAccessFile.java:419) and com.squareup.tape.QueueFile.readHeader(:165). As such, it can’t be “prevented” unless you don’t read all the bytes (which you typically want to), just catch it like so; catch(EOFException e) { /* ignore */ } 🙂
https://docs.oracle.com/javase/7/docs/api/java/io/EOFException.html

Leave a Comment