public abstract class FilteredBufferedReader extends BufferedReader
BufferedReader class,
as the result is guaranteed to behave as expected.
To use this class, you have to implement the filterLine(String) method.
For example:
BufferedReader reader = new FilteredBufferedReader(new FileReader(in)) {
public String filterLine(String line) {
return line.trim().toLowerCase();
}
};
In this example, each attempts to the readLine() method will get the next
line in the input File, after trimming this line and transforming it to lower case.| Constructor and Description |
|---|
FilteredBufferedReader(Reader in)
Create a buffering character-input stream that uses a default-sized input buffer.
|
FilteredBufferedReader(Reader in,
int sz)
Create a buffering character-input stream that uses an input buffer of the specified size.
|
| Modifier and Type | Method and Description |
|---|---|
abstract String |
filterLine(String line)
This abstract method allows to filter each line which is read by this Reader.
|
void |
mark(int readAheadLimit)
Mark the present position in the stream.
|
int |
read()
Read a single character.
|
int |
read(char[] cbuf)
Read characters into an array.
|
int |
read(char[] cbuf,
int off,
int len)
Read characters into a portion of an array.
|
String |
readLine()
Read a line of text.
|
boolean |
ready()
Tell whether this stream is ready to be read.
|
void |
reset()
Resets the stream to the most recent mark.
|
long |
skip(long n)
Skip characters.
|
close, lines, markSupportedpublic FilteredBufferedReader(Reader in)
in - the readerpublic FilteredBufferedReader(Reader in, int sz)
in - the readersz - the size of the bufferpublic String readLine() throws IOException
Remark :As for all read methods, the lines will be filtered by the
filterLine(String) method.
readLine in class BufferedReaderIOExceptionBufferedReader.readLine(),
filterLine(String)public abstract String filterLine(String line)
public String filterLine(String line) {
return line;
}
line - the linepublic int read()
throws IOException
filterLine(String) method.read in class BufferedReaderIOExceptionBufferedReader.read(),
filterLine(String)public int read(char[] cbuf,
int off,
int len)
throws IOException
filterLine(String) method.read in class BufferedReaderIOExceptionBufferedReader.read(char[], int, int),
filterLine(String)public int read(char[] cbuf)
throws IOException
filterLine(String) method.read in class ReaderIOExceptionReader.read(char[]),
filterLine(String)public boolean ready()
throws IOException
ready in class BufferedReaderIOExceptionBufferedReader.ready()public long skip(long n)
throws IOException
skip in class BufferedReaderIOExceptionBufferedReader.skip(long)public void mark(int readAheadLimit)
throws IOException
readLine()
method.mark in class BufferedReaderIOExceptionBufferedReader.mark(int)public void reset()
throws IOException
reset in class BufferedReaderIOExceptionmark(int),
BufferedReader.reset()