org.apache.commons.csv
Class ExtendedBufferedReader
BufferedReader
org.apache.commons.csv.ExtendedBufferedReader
public class ExtendedBufferedReader
extends BufferedReader
ExtendedBufferedReader
A special reader decorater which supports more
sophisticated access to the underlying reader object.
In particular the reader supports a look-ahead option,
which allows you to see the next char returned by
next().
Furthermore the skip-method supports skipping until
(but excluding) a given char. Similar functionality
is supported by the reader as well.
int | getLineNumber() - Returns the nof line read
ATTENTION: the skip-method does invalidate the line-number counter
|
int | lookAhead() - Returns the next char in the stream without consuming it.
|
boolean | markSupported()
|
int | read() - Reads the next char from the input stream.
|
int | read(char[] buf, int off, int len) - Non-blocking reading of len chars into buffer buf starting
at bufferposition off.
|
int | readAgain() - Returns the last read character again.
|
String | readLine()
|
String | readUntil(char c) - Reads all characters up to (but not including) the given character.
|
long | skip(long n) - Skips char in the stream
ATTENTION: invalidates the line-counter !!!!!
|
long | skipUntil(char c) - Skips all chars in the input until (but excluding) the given char
|
END_OF_STREAM
public static final int END_OF_STREAM
the end of stream symbol
UNDEFINED
public static final int UNDEFINED
undefined state for the lookahead char
lastChar
private int lastChar
the last char returned
lineCounter
private int lineCounter
the line counter
lookaheadChar
private int lookaheadChar
the lookahead chars
ExtendedBufferedReader
public ExtendedBufferedReader(Reader r)
Created extended buffered reader using default buffer-size
ExtendedBufferedReader
public ExtendedBufferedReader(Reader r,
int bufSize)
Create extended buffered reader using the given buffer-size
getLineNumber
public int getLineNumber()
Returns the nof line read
ATTENTION: the skip-method does invalidate the line-number counter
- the current-line-number (or -1)
lookAhead
public int lookAhead()
throws IOException
Returns the next char in the stream without consuming it.
Remember the next char read by read(..) will always be
identical to lookAhead().
- the next char (without consuming it) or END_OF_STREAM
markSupported
public boolean markSupported()
read
public int read()
throws IOException
Reads the next char from the input stream.
- the next char or END_OF_STREAM if end of stream has been reached.
read
public int read(char[] buf,
int off,
int len)
throws IOException
Non-blocking reading of len chars into buffer buf starting
at bufferposition off.
performs an iteratative read on the underlying stream
as long as the following conditions hold:
- less than len chars have been read
- end of stream has not been reached
- next read is not blocking
- nof chars actually read or END_OF_STREAM
readAgain
public int readAgain()
Returns the last read character again.
- the last read char or UNDEFINED
readLine
public String readLine()
throws IOException
- A String containing the contents of the line, not
including any line-termination characters, or null
if the end of the stream has been reached
readUntil
public String readUntil(char c)
throws IOException
Reads all characters up to (but not including) the given character.
c
- the character to read up to
- the string up to the character
c
skip
public long skip(long n)
throws IllegalArgumentException,
IOException
Skips char in the stream
ATTENTION: invalidates the line-counter !!!!!
skipUntil
public long skipUntil(char c)
throws IllegalArgumentException,
IOException
Skips all chars in the input until (but excluding) the given char