writeChannel

fun File.writeChannel(pool: ObjectPool<ByteBuffer>): ByteWriteChannel

Open a write channel for file and launch a coroutine to read from it. The coroutine is launched on Dispatchers.IO.


fun File.writeChannel(coroutineContext: CoroutineContext = Dispatchers.IO): ByteWriteChannel

Open a write channel for the file and launch a coroutine to read from it. Please note that file writing 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.