Package io.ktor.utils.io.jvm.javaio

Functions

Link copied to clipboard
suspend fun ByteReadChannel.copyTo(out: OutputStream, limit: Long = Long.MAX_VALUE): Long

Copies up to limit bytes from this byte channel to out stream suspending on read channel and blocking on output

suspend fun InputStream.copyTo(channel: ByteWriteChannel, limit: Long = Long.MAX_VALUE): Long

Copies up to limit bytes from this input stream to CIO byte channel blocking on reading this stream and suspending on channel if required

Link copied to clipboard
fun InputStream.toByteReadChannel(context: CoroutineContext = Dispatchers.IO, pool: ObjectPool<ByteBuffer>): ByteReadChannel
@JvmName(name = "toByteReadChannelWithArrayPool")
fun InputStream.toByteReadChannel(context: CoroutineContext = Dispatchers.IO, pool: ObjectPool<ByteArray> = ByteArrayPool): ByteReadChannel

Open a channel and launch a coroutine to copy bytes from the input stream to the channel. Please note that it may block your async code when started on Dispatchers.Unconfined since InputStream is blocking on it's nature

Link copied to clipboard
fun ByteReadChannel.toInputStream(parent: Job? = null): InputStream

Create blocking java.io.InputStream for this channel that does block every time the channel suspends at read Similar to do reading in runBlocking however you can pass it to regular blocking API

Link copied to clipboard
fun ByteWriteChannel.toOutputStream(parent: Job? = null): OutputStream

Create blocking java.io.OutputStream for this channel that does block every time the channel suspends at write Similar to do reading in runBlocking however you can pass it to regular blocking API