public class LineIterator
extends java.lang.Object
implements java.util.Iterator
repeat()
method causes the last
line iterated to be repeated once.Constructor and Description |
---|
LineIterator(java.io.BufferedReader reader)
Creates an iterator for the lines returned by a
BufferedReader . |
LineIterator(java.io.InputStream stream)
Creates an iterator for the lines returned by an
InputStream . |
LineIterator(java.io.Reader reader)
Creates an iterator for the lines returned by a
Reader . |
Modifier and Type | Method and Description |
---|---|
int |
getLineCount()
Gets the number of the lines iterated so far.
|
boolean |
hasNext()
Gets whether the iterator has iterated all lines available from the reader.
|
java.lang.Object |
next()
Gets the next uniterated line available from the reader, or the last
iterated line if
repeat() was invoked. |
void |
remove() |
void |
repeat()
Repeatd the last iterated line.
|
public LineIterator(java.io.BufferedReader reader)
BufferedReader
.public LineIterator(java.io.Reader reader)
Reader
. The reader
is wrapped in a BufferedReader
if it is not already one.public LineIterator(java.io.InputStream stream)
InputStream
. The
input stream is wrapped in a BufferedReader
.public boolean hasNext()
hasNext
in interface java.util.Iterator
public java.lang.Object next()
repeat()
was invoked.next
in interface java.util.Iterator
public void repeat()
java.util.NoSuchElementException
- if no line has been iterated.public int getLineCount()
public void remove()
remove
in interface java.util.Iterator
java.lang.UnsupportedOperationException