Extensions for java.io.InputStream

copyTo

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