SkyEpub SDK for Android 7
 All Classes Functions Variables
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
com.skytree.epub.LineIterator Class Reference
Inheritance diagram for com.skytree.epub.LineIterator:

Public Member Functions

 LineIterator (final Reader reader) throws IllegalArgumentException
 
boolean hasNext ()
 
Object next ()
 
String nextLine ()
 
void close ()
 
void remove ()
 

Static Public Member Functions

static void closeQuietly (LineIterator iterator)
 

Protected Member Functions

boolean isValidLine (String line)
 

Detailed Description

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
Stephen Colebourne
Sandy McArthur
Version
Id:
LineIterator.java 437567 2006-08-28 06:39:07Z bayard
Since
Commons IO 1.2

Constructor & Destructor Documentation

com.skytree.epub.LineIterator.LineIterator ( final Reader  reader) throws IllegalArgumentException

Constructs an iterator of the lines for a Reader.

Parameters
readerthe Reader to read from, not null
Exceptions
IllegalArgumentExceptionif the reader is null

Member Function Documentation

void com.skytree.epub.LineIterator.close ( )

Closes the underlying Reader quietly. This method is useful if you only want to process the first few lines of a larger file. If you do not close the iterator then the Reader remains open. This method can safely be called multiple times.

static void com.skytree.epub.LineIterator.closeQuietly ( LineIterator  iterator)
static

Closes the iterator, handling null and ignoring exceptions.

Parameters
iteratorthe iterator to close
boolean com.skytree.epub.LineIterator.hasNext ( )

Indicates whether the Reader has more lines. If there is an IOException then close() will be called on this instance.

Returns
true if the Reader has more lines
Exceptions
IllegalStateExceptionif an IO exception occurs
boolean com.skytree.epub.LineIterator.isValidLine ( String  line)
protected

Overridable method to validate each line that is returned.

Parameters
linethe line that is to be validated
Returns
true if valid, false to remove from the iterator
Object com.skytree.epub.LineIterator.next ( )

Returns the next line in the wrapped Reader.

Returns
the next line from the input
Exceptions
NoSuchElementExceptionif there is no line to return
String com.skytree.epub.LineIterator.nextLine ( )

Returns the next line in the wrapped Reader.

Returns
the next line from the input
Exceptions
NoSuchElementExceptionif there is no line to return
void com.skytree.epub.LineIterator.remove ( )

Unsupported.

Exceptions
UnsupportedOperationExceptionalways

The documentation for this class was generated from the following file: