The readInt()
function from java.io.DataInputStream
is as follows:
public final int readInt() throws IOException {
int ch1 = in.read();
int ch2 = in.read();
int ch3 = in.read();
int ch4 = in.read();
if ((ch1 | ch2 | ch3 | ch4) < 0)
throw new EOFException();
return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
}
In the function, you can see that it throws an EOFException
(end of file exception) when (ch1|ch2|ch3|ch4)<0
. But I was under the influence that the standard EOF byte was -1. (That is, 255, 0xFF, 0b11111111, or whatever notation you prefer...) This function, however, only checks to see if any of the bytes are negative. So... What's going on here?