jvmMain.it.unibo.tuprolog.solve.channel.ReaderChannel.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of solve-jvm Show documentation
Show all versions of solve-jvm Show documentation
Resolution-agnostic API for logic solvers
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