public class LineStream extends AbstractObjectStream<String>
Stream that reads lines from a file.
Constructor and Description |
---|
LineStream(BufferedReader in)
Construct a stream reading lines from a buffered reader.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
No-op implementation of the
ObjectStream.close() method. |
int |
getLineNumber()
Return the number of the line returned by the last call to
readObject() . |
static LineStream |
openFile(File file)
Open a delimited text stream as a file.
|
static LineStream |
openFile(File file,
CompressionMode comp)
Open a delimited text stream as a file.
|
String |
readObject()
Read the next object from this stream.
|
ObjectStream<List<String>> |
tokenize(org.apache.commons.lang3.text.StrTokenizer tok) |
iterator
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public LineStream(@WillCloseWhenClosed @Nonnull BufferedReader in)
Construct a stream reading lines from a buffered reader.
in
- The input reader.public static LineStream openFile(File file) throws FileNotFoundException
Open a delimited text stream as a file.
file
- The file to open.FileNotFoundException
- if there is an error opening the file.public static LineStream openFile(File file, CompressionMode comp) throws IOException
Open a delimited text stream as a file.
file
- The file to open.FileNotFoundException
- if there is an error opening the file.IOException
@Nullable public String readObject()
ObjectStream
Read the next object from this stream.
null
if at the end of the stream.public int getLineNumber()
Return the number of the line returned by the last call to readObject()
.
public void close()
AbstractObjectStream
No-op implementation of the ObjectStream.close()
method.
close
in interface Closeable
close
in interface AutoCloseable
close
in interface ObjectStream<String>
close
in class AbstractObjectStream<String>
public ObjectStream<List<String>> tokenize(org.apache.commons.lang3.text.StrTokenizer tok)