DataInputStream.readByte API does not say it return -1 on EOS, it says
Returns:the next byte of this input stream as a signed 8-bit byte.
Throws: EOFException - if this input stream has reached the end.
It assumes that when working withh DataInputStream.readByte we know how many bytes are left in the stream. Otherwise we can use EOFException as an indicator of EOS.
BTW If you use read() you will get -1 on EOS without EOFException
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…