readTo

suspend fun ByteReadChannel.readTo(sink: RawSink, limit: Long = Long.MAX_VALUE): Long(source)

Reads bytes from this ByteReadChannel and writes them to the specified sink. If an exception is thrown, the channel and sink are closed.

Report a problem

Return

the number of bytes transferred

Parameters

sink

the destination to write bytes to

limit

the maximum number of bytes to transfer, defaults to Long.MAX_VALUE

Throws

if the channel is closed with an error