The java.io.InputStream.read(byte b, int off, int len) method reads upto len bytes of data from the input stream into an array of bytes. If the parameter len is zero, then no bytes are read and 0 is returned; else there is an attempt to read at least one byte. If the stream is at the end of the file, the value returned is -1.
- b − The destination byte array.
- off − The start offset in array b at which the data is written.
- len − The number of bytes to read.
The method returns the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
- IOException − If an I/O error occurs.
- NullPointerException − If b is null.
- IndexOutOfBoundsException − If off is negative, len is negative, or len is greater than b.length – off.