Extensions for java.io.Reader

JVM
1.0

buffered

Returns a buffered reader wrapping this Reader, or this Reader itself if it is already buffered.

fun Reader.buffered(
    bufferSize: Int = DEFAULT_BUFFER_SIZE
): BufferedReader
JVM
1.0

copyTo

Copies this reader to the given out writer, returning the number of characters copied.

fun Reader.copyTo(
    out: Writer,
    bufferSize: Int = DEFAULT_BUFFER_SIZE
): Long
JVM
1.0

forEachLine

Iterates through each line of this reader, calls action for each line read and closes the Reader when it's completed.

fun Reader.forEachLine(action: (String) -> Unit)
JVM
1.0

readLines

Reads this reader content as a list of lines.

fun Reader.readLines(): List<String>
JVM
1.0

readText

Reads this reader completely as a String.

fun Reader.readText(): String
JVM
1.0

useLines

Calls the block callback giving it a sequence of all the lines in this file and closes the reader once the processing is complete.

fun <T> Reader.useLines(block: (Sequence<String>) -> T): T