public class LineSegmentReader extends Object
LineSegments from a stream.
| Constructor and Description |
|---|
LineSegmentReader(Reader reader)
Constructs a new
LineSegmentReader. |
LineSegmentReader(Reader reader,
int bufferSize,
int minBufferFilling,
int bufferEnlargement)
Constructs a new
LineSegmentReader. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the stream.
|
InputPosition |
getInputPosition()
Returns information about the current position within the input stream.
|
void |
mark()
Marks the current position in the stream so that calling
reset(boolean) will return to this position. |
LineSegment |
read()
Reads a
LineSegment from the stream. |
LineSegment |
read(int limit)
Reads a
LineSegment from the stream with an upper bound for the length of its content. |
LineSegment |
read(int specialTerminator,
int limit)
Reads a
LineSegment from the stream. |
void |
removeMarker()
Removes the marker.
|
void |
reset(boolean removeMarker)
Moves back to the position marked with
mark() before. |
void |
skipLine()
Skips the current line, i.
|
public LineSegmentReader(Reader reader)
LineSegmentReader.reader - the reader to access the stream withpublic LineSegmentReader(Reader reader, int bufferSize, int minBufferFilling, int bufferEnlargement)
LineSegmentReader.reader - the reader to access the stream withbufferSize - the initial size of the character bufferminBufferFilling - the minimum number of characters to fill the buffer with. Only relevant when a mark is
set.bufferEnlargement - the number of characters to enlarge the buffer if it gets too small. Only relevant when
a mark is set.public LineSegment read() throws IOException
LineSegment from the stream.
The segment is terminated either with a line break or end of stream.
LineSegment or null if there are no characters left on the streamIOException - if an I/O error occurspublic LineSegment read(int limit) throws IOException
LineSegment from the stream with an upper bound for the length of its content.
The segment is either terminated (with a line break or end of stream) or not (if the limit is reached).
limit - the upper bound for the size of the LineSegment (length of its content).LineSegment or null if there are no characters left on the streamIOException - if an I/O error occurspublic LineSegment read(int specialTerminator, int limit) throws IOException
LineSegment from the stream.specialTerminator - the character to use as a special terminator for the LineSegement or -1, if
only the standard terminators shall be used.limit - the upper bound for the size of the LineSegment (length of its content).LineSegment or null if there are no characters left on the streamIOException - if an I/O error occurspublic void skipLine()
throws IOException
IOException - if an I/O error occurspublic InputPosition getInputPosition()
public void mark()
reset(boolean) will return to this position.
Note: You should remove the marker with removeMarker() if you do not need it any more.
public void reset(boolean removeMarker)
mark() before.removeMarker - true, if the marker should be removed afterwardspublic void removeMarker()
public void close()
throws IOException
IOException - if an I/O error occursCopyright © 2014. All rights reserved.