|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mahout.common.FileLineIterator
public final class FileLineIterator
Iterates over the lines of a text file. This assumes the text file's lines are delimited in a manner
consistent with how BufferedReader
defines lines.
This class will uncompress files that end in .zip or .gz accordingly, too.
Constructor Summary | |
---|---|
FileLineIterator(java.io.File file)
Creates a over a given file, assuming a UTF-8 encoding. |
|
FileLineIterator(java.io.File file,
boolean skipFirstLine)
Creates a over a given file, assuming a UTF-8 encoding. |
|
FileLineIterator(java.io.File file,
java.nio.charset.Charset encoding,
boolean skipFirstLine)
Creates a over a given file, using the given encoding. |
|
FileLineIterator(java.io.InputStream is)
|
|
FileLineIterator(java.io.InputStream is,
boolean skipFirstLine)
|
|
FileLineIterator(java.io.InputStream is,
java.nio.charset.Charset encoding,
boolean skipFirstLine)
|
Method Summary | |
---|---|
void |
close()
|
boolean |
hasNext()
|
java.lang.String |
next()
|
java.lang.String |
peek()
|
void |
remove()
|
void |
skip(int n)
Skip the next n elements supplied by this Iterator . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileLineIterator(java.io.File file) throws java.io.IOException
java.io.FileNotFoundException
- if the file does not exist
java.io.IOException
- if the file cannot be readpublic FileLineIterator(java.io.File file, boolean skipFirstLine) throws java.io.IOException
java.io.FileNotFoundException
- if the file does not exist
java.io.IOException
- if the file cannot be readpublic FileLineIterator(java.io.File file, java.nio.charset.Charset encoding, boolean skipFirstLine) throws java.io.IOException
java.io.FileNotFoundException
- if the file does not exist
java.io.IOException
- if the file cannot be readpublic FileLineIterator(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public FileLineIterator(java.io.InputStream is, boolean skipFirstLine) throws java.io.IOException
java.io.IOException
public FileLineIterator(java.io.InputStream is, java.nio.charset.Charset encoding, boolean skipFirstLine) throws java.io.IOException
java.io.IOException
Method Detail |
---|
public java.lang.String peek()
public boolean hasNext()
hasNext
in interface java.util.Iterator<java.lang.String>
public java.lang.String next()
next
in interface java.util.Iterator<java.lang.String>
public void remove()
remove
in interface java.util.Iterator<java.lang.String>
java.lang.UnsupportedOperationException
public void skip(int n)
SkippingIterator
Iterator
. If there are less than n elements remaining,
this skips all remaining elements in the Iterator
. This method has the same effect as calling
Iterator.next()
n times, except that it will never throw NoSuchElementException
.
skip
in interface SkippingIterator<java.lang.String>
public void close()
close
in interface java.io.Closeable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |