read

open override fun read(): Int

See the general contract of the read method of InputStream.

Return

the next byte of data, or -1 if the end of the stream is reached.

See also

java.io.FilterInputStream

in

Throws

IOException

if this input stream has been closed by invoking its .close method, or an I/O error occurs.


open override fun read(b: ByteArray, off: Int, len: Int): Int

Reads bytes from this byte-input stream into the specified byte array, starting at the given offset.

This method implements the general contract of the corresponding read method of the InputStream class. As an additional convenience, it attempts to read as many bytes as possible by repeatedly invoking the read method of the underlying stream. This iterated read continues until one of the following conditions becomes true:

  • The specified number of bytes have been read,

  • The read method of the underlying stream returns -1, indicating end-of-file, or

  • The available method of the underlying stream returns zero, indicating that further input requests would block.

If the first read on the underlying stream returns -1 to indicate end-of-file then this method returns -1. Otherwise, this method returns the number of bytes actually read.

Subclasses of this class are encouraged, but not required, to attempt to read as many bytes as possible in the same fashion.

Return

the number of bytes read, or -1 if the end of the stream has been reached.

Parameters

b

destination buffer.

off

offset at which to start storing bytes.

len

maximum number of bytes to read.

Throws

IOException

if this input stream has been closed by invoking its .close method, or an I/O error occurs.