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
LineIterator.close() or
LineIterator.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 |