readAtMost

abstract fun readAtMost(pos: Long, buf: ByteArray, off: Int, len: Int): Int(source)

Reads at most len bytes from the data source starting at the given pos into the buf array, starting at offset off.

This function attempts to read up to len bytes into the buffer. Fewer bytes may be read only if the end of the data is reached. This method never blocks indefinitely.

Return

The number of bytes actually read, or 0 if the end of data is reached

Parameters

pos

The starting position in the data source (must be ≥ 0; values beyond data size are treated as EOF)

buf

The destination byte array

off

The starting offset in the buffer (must be in [0, buf.size))

len

The maximum number of bytes to read (must be in 0, buf.size - off)

Throws

If pos< 0, or if off/len are invalid for buf

If an I/O error occurs (for file/network-backed implementations)


open fun readAtMost(pos: Long, buf: ByteArray): Int(source)

Reads at most buf.size bytes from the data source starting at pos into the given buf.

Equivalent to: readAtMost(pos, buf, 0, buf.size)

Throws

If an I/O error occurs