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 {@link #close()} or {@link #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);
}
|