exhausted

abstract fun exhausted(): Boolean(source)

Returns true if there are no more bytes in this source.

The call of this method will block until there are bytes to read or the source is definitely exhausted.

Throws

when the source is closed.

Samples

import kotlinx.io.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val singleByteSource = object : RawSource {
    private var exhausted = false
    override fun readAtMostTo(sink: Buffer, byteCount: Long): Long = when {
        byteCount == 0L -> 0L
        exhausted -> -1L
        else -> {
            exhausted = true
            sink.writeByte(42)
            1L
        }
    }

    override fun close() = Unit
}

val source = singleByteSource.buffered()

assertFalse(source.exhausted())
assertContentEquals(byteArrayOf(42), source.readByteArray())
assertTrue(source.exhausted()) 
   //sampleEnd
}