flow

fun AsynchronousFileChannel.flow(bufferSize: Int = 1024): Flow<ByteArray>

Creates a Flow of ByteArrays by reading the content of this AsynchronousFileChannel using the given bufferSize as the chunk size for each emitted ByteArray.

Return

A Flow of ByteArrays representing chunks of content from this channel.

Example usage:

val channel: AsynchronousFileChannel = ...
val byteArrayFlow = channel.flow(1024)
byteArrayFlow.collect { bytes -> ... }

Parameters

bufferSize

The size of the buffer to read data chunks into. Defaults to 1024.