readAsFlow

fun Path.readAsFlow(bufferSize: Int = 1024, vararg options: OpenOption = arrayOf( StandardOpenOption.READ )): Flow<ByteArray>

Reads the content of the file at this Path into a Flow of ByteArrays. Each emitted ByteArray represents a chunk of the file content based on the specified bufferSize.

Return

A Flow of ByteArrays representing chunks of content from the file.

Example usage:

val filePath: Path = ...
val byteArrayFlow = filePath.readAsFlow(1024)
byteArrayFlow.collect { bytes -> ... }

Parameters

bufferSize

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

options

The options specifying how the file is opened. Defaults to StandardOpenOption.READ.