readChannel

fun File.readChannel(start: Long = 0, endInclusive: Long = -1, coroutineContext: CoroutineContext = Dispatchers.IO): ByteReadChannel

Open a read channel for file and launch a coroutine to fill it. Please note that file reading is blocking so if you are starting it on Dispatchers.Unconfined it may block your async code and freeze the whole application when runs on a pool that is not intended for blocking operations. This is why coroutineContext should have Dispatchers.IO or a coroutine dispatcher that is properly configured for blocking IO.


fun Path.readChannel(start: Long, endInclusive: Long): ByteReadChannel
fun Path.readChannel(): ByteReadChannel

Open a read channel for file and launch a coroutine to fill it. Please note that file reading is blocking so if you are starting it on Dispatchers.Unconfined it may block your async code