LineOutputFeed

actual abstract class LineOutputFeed(source)

Scans buffered input and dispatches lines, disregarding line breaks CR (\r), LF (\n), & CRLF (\r\n).

After reading operations are exhausted, calling close will assume any buffered input remaining is terminating and dispatch it as a line, and then dispatch null to indicate End Of Stream.

This is NOT thread safe.

See also

expect abstract class LineOutputFeed(source)

Scans buffered input and dispatches lines, disregarding line breaks CR (\r), LF (\n), & CRLF (\r\n).

After reading operations are exhausted, calling close will assume any buffered input remaining is terminating and dispatch it as a line, and then dispatch null to indicate End Of Stream.

This is NOT thread safe.

e.g. (Jvm)

val feed = ReadBuffer.lineOutputFeed { line ->
    println(line ?: "--EOS--")
}

myInputStream.use { iStream ->
    val buf = ReadBuffer.allocate()

    try {
        while(true) {
            val read = iStream.read(buf.buf)
            if (read == -1) break
            feed.onData(buf, read)
        }
    } finally {

        // done reading, dispatch last line
        // (if buffered), and dispatch null
        // to indicate EOS
        feed.close()
    }
}

See also

actual abstract class LineOutputFeed(source)

Scans buffered input and dispatches lines, disregarding line breaks CR (\r), LF (\n), & CRLF (\r\n).

After reading operations are exhausted, calling close will assume any buffered input remaining is terminating and dispatch it as a line, and then dispatch null to indicate End Of Stream.

This is NOT thread safe.

e.g. (Jvm)

val feed = ReadBuffer.lineOutputFeed { line ->
    println(line ?: "--EOS--")
}

myInputStream.use { iStream ->
    val buf = ReadBuffer.allocate()

    try {
        while(true) {
            val read = iStream.read(buf.buf)
            if (read == -1) break
            feed.onData(buf, read)
        }
    } finally {

        // done reading, dispatch last line
        // (if buffered), and dispatch null
        // to indicate EOS
        feed.close()
    }
}

See also

Functions

Link copied to clipboard
actual abstract fun close()
expect abstract fun close()
actual abstract fun close()
Link copied to clipboard
actual abstract fun onData(buf: ReadBuffer, len: Int)
expect abstract fun onData(buf: ReadBuffer, len: Int)
actual abstract fun onData(buf: ReadBuffer, len: Int)