The Javadoc for DataInput.readFully(byte[] b) states:
Reads a few bytes from the input stream and saves them to buffer array b . The number of bytes read is equal to the length b .
The Javadoc for DataInputStream.read(byte[] b) states:
Reads a certain number of bytes from the contained input stream and stores them in buffer array b . The number of bytes actually read is returned as an integer. This method is blocked until the input is accessible, the end of the file, or an exception is thrown .
Basically, readFully() will read exactly b.length bytes, while read() will read up to b.length , maybe less, regardless of what is available from the input stream.
source share