All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.it.unibo.tuprolog.solve.channel.ReaderChannel.kt Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
package it.unibo.tuprolog.solve.channel

import it.unibo.tuprolog.solve.channel.impl.AbstractInputChannel
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import java.io.Reader

class ReaderChannel(val reader: Reader) : AbstractInputChannel() {
    constructor(inputStream: InputStream) : this(InputStreamReader(inputStream))

    override fun readActually(): String? = reader.read().takeIf { it >= 0 }?.toChar()?.toString()

    override val available: Boolean
        @Synchronized
        get() =
            try {
                reader.ready()
            } catch (_: IOException) {
                false
            }

    @Synchronized
    override fun close() {
        reader.close()
        super.close()
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy