open class LineIterator : MutableIterator<Any?>
An Iterator over the lines in a Reader
.
LineIterator
holds a reference to an open Reader
. When you have finished with the iterator you should close the reader to free internal resources. This can be done by closing the reader directly, or by calling the #close()
or #closeQuietly(LineIterator)
method on the iterator.
The recommended usage pattern is:
LineIterator it = FileUtils.lineIterator(file, "UTF-8");
try {
while (it.hasNext()) {
String line = it.nextLine();
/// do something with line
}
} finally {
LineIterator.closeQuietly(iterator);
}
Author
Niall Pemberton
Author
Stephen Colebourne
Author
Sandy McArthur
Version
$Id: LineIterator.java 437567 2006-08-28 06:39:07Z bayard $
Since
Commons IO 1.2
LineIterator(reader: Reader!)
Constructs an iterator of the lines for a |
open fun close(): Unit
Closes the underlying |
|
open static fun closeQuietly(iterator: LineIterator!): Unit
Closes the iterator, handling null and ignoring exceptions. |
|
open fun hasNext(): Boolean
Indicates whether the |
|
open fun isValidLine(line: String!): Boolean
Overridable method to validate each line that is returned. |
|
open fun next(): Any?
Returns the next line in the wrapped |
|
open fun nextLine(): String!
Returns the next line in the wrapped |
|
open fun remove(): Unit
Unsupported. |