|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.Reader net.sf.beanlib.io.FastLineNumberReader
public class FastLineNumberReader
A non-thread-safe fast line number reader that preserves the end-of-line character(s).
Code is originally based on BufferedReader
.
Nested Class Summary | |
---|---|
private static class |
FastLineNumberReader.EolEnum
End-of-line enums. |
Field Summary | |
---|---|
private char[] |
charbuf
Character buffer. |
private boolean |
checkNextLF
True iff we need to read in more data into the character buffer to check if the next char is a LF; False otherwise. |
private static int |
DEFAULT_CHAR_BUFFER_SIZE
|
private static int |
DEFAULT_LINE_LENGTH
|
private FastLineNumberReader.EolEnum |
eolEnum
Last End of line. |
private int |
lineNumber
Current line number. |
private int |
nextCharIdx
Index to the next character. |
private int |
numCharInBuf
Number of characters in the character buffer. |
private Reader |
reader
The underlying reader. |
Fields inherited from class java.io.Reader |
---|
lock |
Constructor Summary | |
---|---|
FastLineNumberReader(Reader in)
Create a buffering character-input stream that uses a default-sized input buffer. |
|
FastLineNumberReader(Reader in,
int sz)
Create a buffering character-input stream that uses an input buffer of the specified size. |
Method Summary | |
---|---|
void |
close()
|
private void |
fill()
Reads and fills the internal character buffer. |
int |
getLineNumber()
Returns the current line number. |
int |
read(char[] cbuf,
int off,
int len)
|
private int |
read1(char[] cbuf,
int off,
int len)
|
String |
readEndOfLine()
Returns the end of line character(s) as string. |
String |
readLine()
Returns the next line read. |
Methods inherited from class java.io.Reader |
---|
mark, markSupported, read, read, read, ready, reset, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static int DEFAULT_CHAR_BUFFER_SIZE
private static int DEFAULT_LINE_LENGTH
private Reader reader
private char[] charbuf
private int numCharInBuf
private int nextCharIdx
private boolean checkNextLF
private int lineNumber
private FastLineNumberReader.EolEnum eolEnum
Constructor Detail |
---|
public FastLineNumberReader(Reader in, int sz)
in
- A Readersz
- Input-buffer size
IllegalArgumentException
- If sz is <= 0public FastLineNumberReader(Reader in)
in
- A ReaderMethod Detail |
---|
private void fill() throws IOException
IOException
public int read(char[] cbuf, int off, int len) throws IOException
read
in class Reader
IOException
private int read1(char[] cbuf, int off, int len) throws IOException
IOException
public void close() throws IOException
close
in interface Closeable
close
in class Reader
IOException
public String readEndOfLine() throws IOException
IOException
public int getLineNumber()
public String readLine() throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |