Reads some bytes from an input stream and stores them into the buffer array
b
. The number of bytes read is equal to the length of
b
.
This method blocks until one of the following conditions occurs:
b.length
bytes of input data are available, in which case a normal return is made. - End of file is detected, in which case an
EOFException
is thrown. - An I/O error occurs, in which case an
IOException
other than EOFException
is thrown.
If b
is null
, a NullPointerException
is thrown. If b.length
is zero, then no bytes are read. Otherwise, the first byte read is stored into element b[0]
, the next one into b[1]
, and so on. If an exception is thrown from this method, then it may be that some but not all bytes of b
have been updated with data from the input stream.
@param b the buffer into which the data is read.
@exception EOFException if this stream reaches the end before reading all the bytes.
@exception IOException if an I/O error occurs.