public class LineScanner extends Reader
This class was originally taken from Apache Harmony. The source is no longer online.
Read a properties file line by line using line().
The idea is that as we read lines, we return not the line text but a Line object which has knowledge of its internal parts, such as if the line has a key, is an extended line, etc.
There is one extension: a comment line which starts with #;; is treated as transient (not read in). This token is used later to generate a transient header and footer if desired.
Note: because this is a Reader, the caller must call close() on it when done.
Line,
LineEnding,
PropertiesToken,
PropertiesTokenType| Modifier and Type | Field and Description |
|---|---|
private char[] |
buf |
private LineEnding |
delimiter |
private int |
delimiterLength |
private int |
end |
private Reader |
in |
private int |
mark |
private int |
markLimit |
private int |
pos |
private long |
totalRead |
| Constructor and Description |
|---|
LineScanner(Reader in) |
LineScanner(Reader in,
int size) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
private int |
fillBuf() |
LineEnding |
getDelimiter() |
long |
getTotalRead() |
private boolean |
isClosed() |
Line |
line()
This is the interface into the parser, don't use the other methods (the ones from Reader).
|
void |
mark(int markLimit) |
boolean |
markSupported() |
int |
read() |
int |
read(char[] buffer,
int offset,
int length) |
(package private) String |
readLine() |
boolean |
ready() |
void |
reset() |
long |
skip(long amount) |
private final Reader in
private char[] buf
private int pos
private int end
private int mark
private int markLimit
private long totalRead
private int delimiterLength
private LineEnding delimiter
public LineScanner(Reader in)
public LineScanner(Reader in, int size)
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class ReaderIOExceptionprivate int fillBuf()
throws IOException
IOExceptionprivate boolean isClosed()
public void mark(int markLimit)
throws IOException
mark in class ReaderIOExceptionpublic boolean markSupported()
markSupported in class Readerpublic int read()
throws IOException
read in class ReaderIOExceptionpublic int read(char[] buffer,
int offset,
int length)
throws IOException
read in class ReaderIOExceptionpublic Line line()
String readLine() throws IOException
IOExceptionpublic boolean ready()
throws IOException
ready in class ReaderIOExceptionpublic void reset()
throws IOException
reset in class ReaderIOExceptionpublic long skip(long amount)
throws IOException
skip in class ReaderIOExceptionpublic long getTotalRead()
public LineEnding getDelimiter()
Copyright © 2011–2016 David R. Smith. All rights reserved.