public final class FileLineIterator extends com.google.common.collect.AbstractIterator<String> implements SkippingIterator<String>, Closeable
BufferedReader
defines lines.
This class will uncompress files that end in .zip or .gz accordingly, too.Constructor and Description |
---|
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) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected String |
computeNext() |
void |
skip(int n)
Skip the next n elements supplied by this
Iterator . |
endOfData, hasNext, next, peek
public FileLineIterator(File file) throws IOException
FileLineIterator
over a given file, assuming a UTF-8 encoding.FileNotFoundException
- if the file does not existIOException
- if the file cannot be readpublic FileLineIterator(File file, boolean skipFirstLine) throws IOException
FileLineIterator
over a given file, assuming a UTF-8 encoding.FileNotFoundException
- if the file does not existIOException
- if the file cannot be readpublic FileLineIterator(File file, Charset encoding, boolean skipFirstLine) throws IOException
FileLineIterator
over a given file, using the given encoding.FileNotFoundException
- if the file does not existIOException
- if the file cannot be readpublic FileLineIterator(InputStream is) throws IOException
IOException
public FileLineIterator(InputStream is, boolean skipFirstLine) throws IOException
IOException
public FileLineIterator(InputStream is, Charset encoding, boolean skipFirstLine) throws IOException
IOException
public FileLineIterator(InputStream is, Charset encoding, boolean skipFirstLine, String filename) throws IOException
IOException
protected String computeNext()
computeNext
in class com.google.common.collect.AbstractIterator<String>
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<String>
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2008–2015 The Apache Software Foundation. All rights reserved.