readFully

open fun readFully(input: InputStream, array: Array<Byte>): Int

Reads as much from input as possible to fill the given array.

This method may invoke read repeatedly to fill the array and only read less bytes than the length of the array if the end of the stream has been reached.

Return

the number of bytes actually read

Parameters

input

stream to read from

array

buffer to fill

Throws

on error


open fun readFully(input: InputStream, array: Array<Byte>, offset: Int, len: Int): Int

Reads as much from input as possible to fill the given array with the given amount of bytes.

This method may invoke read repeatedly to read the bytes and only read less bytes than the requested length if the end of the stream has been reached.

Return

the number of bytes actually read

Parameters

input

stream to read from

array

buffer to fill

offset

offset into the buffer to start filling at

len

of bytes to read

Throws

if an I/O error has occurred


open fun readFully(channel: ReadableByteChannel, byteBuffer: ByteBuffer)

Reads b.remaining() bytes from the given channel starting at the current channel's position.

This method reads repeatedly from the channel until the requested number of bytes are read. This method blocks until the requested number of bytes are read, the end of the channel is detected, or an exception is thrown.

Parameters

channel

the channel to read from

byteBuffer

the buffer into which the data is read.

Throws

- if an I/O error occurs.

- if the channel reaches the end before reading all the bytes.