coRead

suspend fun AsynchronousFileChannel.coRead(bufferSize: Int, position: Long): ByteBuffer

Reads content from this AsynchronousFileChannel into a ByteBuffer of the given bufferSize starting at the specified position using a coroutine-friendly API.

Return

The ByteBuffer containing the read data.

Example usage:

val channel: AsynchronousFileChannel = ...
val buffer = channel.coRead(1024, 0)

Parameters

bufferSize

The size of the buffer to read data into.

position

The position in the file at which the reading starts.