kotlin.io
Extensions on java.io.BufferedReader

extension functions on class java.io.BufferedReader
from package kotlin.io

Function Summary
fun Reader buffered( [bufferSize: Int]): BufferedReader
Creates a buffered reader, or returns self if Reader is already buffered
fun Reader copyTo(out: Writer, [bufferSize: Int]): Long
Copies this reader to the given output writer, returning the number of bytes copied.
fun Reader forEachLine(block: (String-> Unit): Unit
Iterates through each line of this reader then closing the Reader when its completed
fun BufferedReader lineIterator(): Iterator<String>
fun BufferedReader lines(): Stream<String>
Returns an iterator over each line.
Note the caller must close the underlying BufferedReader
when the iteration is finished; as the user may not complete the iteration loop (e.g. using a method like find() or any() on the iterator
may terminate the iteration early.


We suggest you try the method useLines() instead which closes the stream when the processing is complete.
fun Reader readText(): String
Reads this reader completely as a String
fun <T>
Reader
useLines(block: (Stream<String>) -> T): T
 

Function Detail
source

buffered


 fun Reader.buffered( [bufferSize: Int]): BufferedReader

Creates a buffered reader, or returns self if Reader is already buffered

source

copyTo


 fun Reader.copyTo(out: Writer,  [bufferSize: Int]): Long

Copies this reader to the given output writer, returning the number of bytes copied.

Note it is the callers responsibility to close both of these resources

source

forEachLine


 fun Reader.forEachLine(block: (String-> Unit): Unit

Iterates through each line of this reader then closing the Reader when its completed

source

lineIterator


 fun BufferedReader.lineIterator(): Iterator<String>
source

lines


 fun BufferedReader.lines(): Stream<String>

Returns an iterator over each line.
Note the caller must close the underlying BufferedReader
when the iteration is finished; as the user may not complete the iteration loop (e.g. using a method like find() or any() on the iterator
may terminate the iteration early.


We suggest you try the method useLines() instead which closes the stream when the processing is complete.

source

readText


 fun Reader.readText(): String

Reads this reader completely as a String

Note it is the callers responsibility to close this resource

source

useLines


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


Copyright © 2010-2012. All Rights Reserved.