edu.stanford.nlp.objectbank
Class LineIterator<X>
java.lang.Object
edu.stanford.nlp.util.AbstractIterator<X>
edu.stanford.nlp.objectbank.LineIterator<X>
- All Implemented Interfaces:
- Iterator<X>
public class LineIterator<X>
- extends AbstractIterator<X>
An Iterator that returns a line of a file at a time.
Lines are broken as determined by Java's readLine() method.
The returned lines do not include the newline character.
- Author:
- Christopher Manning
Method Summary |
static
|
getFactory()
Returns a factory that vends LineIterators that read the contents of the
given Reader, splitting on newlines. |
static
|
getFactory(Function<String,X> op)
Returns a factory that vends LineIterators that read the contents of the
given Reader, splitting on newlines. |
boolean |
hasNext()
|
static void |
main(String[] args)
|
X |
next()
|
Object |
peek()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LineIterator
public LineIterator(Reader r)
LineIterator
public LineIterator(Reader r,
Function<String,X> op)
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interface Iterator<X>
- Specified by:
hasNext
in class AbstractIterator<X>
next
public X next()
- Specified by:
next
in interface Iterator<X>
- Specified by:
next
in class AbstractIterator<X>
peek
public Object peek()
getFactory
public static <X> IteratorFromReaderFactory<X> getFactory()
- Returns a factory that vends LineIterators that read the contents of the
given Reader, splitting on newlines.
- Returns:
- An iterator over the lines of a file
getFactory
public static <X> IteratorFromReaderFactory<X> getFactory(Function<String,X> op)
- Returns a factory that vends LineIterators that read the contents of the
given Reader, splitting on newlines.
- Parameters:
op
- A function to be applied to each line before it is returned
- Returns:
- An iterator over the lines of a file
main
public static void main(String[] args)
Stanford NLP Group