asInputStream

Returns an input stream that reads from this source. Closing the stream will also close this source.

Samples

import kotlinx.io.*
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.nio.ByteBuffer
import java.util.zip.GZIPInputStream
import java.util.zip.GZIPOutputStream
import kotlin.test.*

fun main() { 
   //sampleStart 
   val buffer = Buffer()
val data = ByteArray(100) { it.toByte() }

GZIPOutputStream(buffer.asOutputStream()).use {
    it.write(data)
}
val decodedData = GZIPInputStream(buffer.asInputStream()).use {
    it.readBytes()
}
assertContentEquals(data, decodedData) 
   //sampleEnd
}