org.apache.mahout.common.iterator
Class FileLineIterator
java.lang.Object
com.google.common.collect.UnmodifiableIterator<T>
com.google.common.collect.AbstractIterator<String>
org.apache.mahout.common.iterator.FileLineIterator
- All Implemented Interfaces:
- Closeable, Iterator<String>, SkippingIterator<String>
public final class FileLineIterator
- extends com.google.common.collect.AbstractIterator<String>
- implements SkippingIterator<String>, Closeable
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(File file)
Creates a FileLineIterator over a given file, assuming a UTF-8 encoding. |
FileLineIterator(File file,
boolean skipFirstLine)
Creates a FileLineIterator over a given file, assuming a UTF-8 encoding. |
FileLineIterator(File file,
Charset encoding,
boolean skipFirstLine)
Creates a FileLineIterator over a given file, using the given encoding. |
FileLineIterator(InputStream is)
|
FileLineIterator(InputStream is,
boolean skipFirstLine)
|
FileLineIterator(InputStream is,
Charset encoding,
boolean skipFirstLine)
|
FileLineIterator(InputStream is,
Charset encoding,
boolean skipFirstLine,
String filename)
|
| Methods inherited from class com.google.common.collect.AbstractIterator |
endOfData, hasNext, next, peek |
| Methods inherited from class com.google.common.collect.UnmodifiableIterator |
remove |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileLineIterator
public FileLineIterator(File file)
throws IOException
- Creates a
FileLineIterator over a given file, assuming a UTF-8 encoding.
- Throws:
FileNotFoundException - if the file does not exist
IOException - if the file cannot be read
FileLineIterator
public FileLineIterator(File file,
boolean skipFirstLine)
throws IOException
- Creates a
FileLineIterator over a given file, assuming a UTF-8 encoding.
- Throws:
FileNotFoundException - if the file does not exist
IOException - if the file cannot be read
FileLineIterator
public FileLineIterator(File file,
Charset encoding,
boolean skipFirstLine)
throws IOException
- Creates a
FileLineIterator over a given file, using the given encoding.
- Throws:
FileNotFoundException - if the file does not exist
IOException - if the file cannot be read
FileLineIterator
public FileLineIterator(InputStream is)
throws IOException
- Throws:
IOException
FileLineIterator
public FileLineIterator(InputStream is,
boolean skipFirstLine)
throws IOException
- Throws:
IOException
FileLineIterator
public FileLineIterator(InputStream is,
Charset encoding,
boolean skipFirstLine)
throws IOException
- Throws:
IOException
FileLineIterator
public FileLineIterator(InputStream is,
Charset encoding,
boolean skipFirstLine,
String filename)
throws IOException
- Throws:
IOException
computeNext
protected String computeNext()
- Specified by:
computeNext in class com.google.common.collect.AbstractIterator<String>
skip
public void skip(int n)
- Description copied from interface:
SkippingIterator
- Skip the next n elements supplied by this
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.
- Specified by:
skip in interface SkippingIterator<String>
close
public void close()
throws IOException
- Specified by:
close in interface Closeable
- Throws:
IOException
Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.