klyn.io.FileInputStream.readInto
method
public readInto(notnull buffer as Byte[], offset as Long = 0l, length as Long = -1l) as Long
Description

Reads into an existing byte buffer without reopening the file or allocating another buffer. A zero return value means end-of-stream.

Parameters
ParameterDescription
bufferDestination buffer.
offsetFirst destination index.
lengthMaximum bytes to read; -1 fills the remaining buffer.
Returns

Number of bytes actually read.

Throws
  • IOException if the stream is closed or a read fails.
  • IndexException if the requested destination range is invalid.
Example

count = stream.readInto(buffer)