posted 19 years ago
I am using RandomAccessFile(raf).
raf.readBytes(byte b[]) return -1 if end of file is encountered, but I am also using raf.readShort as shown above. readShort() does not return -1 but throws EOFException.
To check for the eof in my code, is catching EOFException the only way? I could use read() or read(byte[]) which return -1 for EOF and then convert the 2 bytes to short, but that is the long way. Is there a better way to do this?