read

open fun read(): Int

Reads a single byte from this stream and returns it as an integer in the range from 0 to 255. Returns -1 if the end of the source string has been reached. If the internal buffer does not contain any available bytes then it is filled from the source stream and the first byte is returned.

Return

the byte read or -1 if the end of the source stream has been reached.

Throws

if this stream is closed or another IOException occurs.


open fun read(    buffer: Array<Byte>,     offset: Int,     byteCount: Int): Int

Reads at most byteCount bytes from this stream and stores them in byte array buffer starting at offset offset. Returns the number of bytes actually read or -1 if no bytes were read and the end of the stream was encountered. If all the buffered bytes have been used, a mark has not been put and the requested number of bytes is larger than the receiver's buffer size, this implementation bypasses the buffer and simply places the results directly into buffer.

Return

the number of bytes actually read or -1 if end of stream.

Parameters

buffer

the byte array in which to store the bytes read.

Throws

if offset < 0 or byteCount < 0, or if offset + byteCount is greater than the size of buffer.

if the stream is already closed or another IOException occurs.