asOutputStream
Returns an output stream that writes to this sink. Closing the stream will also close this sink.
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.Test
import kotlin.test.assertContentEquals
import kotlin.test.assertEquals
import kotlin.test.assertTrue
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
}