public class LineFilterReader extends FilterReader
Modifier and Type | Field and Description |
---|---|
static String |
defaultContinuationChars
Default continuation characters used to specify that two lines
should be joined together.
|
static String |
defaultJoinString
Default join String used when joining two lines together.
|
in
Constructor and Description |
---|
LineFilterReader(Reader in,
StringProcessor strategy)
Creates a new LineFilterReader.
|
Modifier and Type | Method and Description |
---|---|
static void |
processFile(String inputFile,
StringProcessor strategy)
Processes a text file line by line with the given StringProcessor.
|
static void |
processFile(String inputFile,
String outputFile,
StringProcessor strategy)
Processes a text file line by line with the given StringProcessor.
|
int |
read()
Reads a single character.
|
int |
read(char[] cbuf,
int off,
int len)
Reads characters into an array, processing the underlying reader as
they are read.
|
void |
setContinuationChars(String chars)
Sets the continuation characters used to specify that two lines
should be joined together.
|
void |
setJoinString(String str)
Sets the String used when joining lines together.
|
close, mark, markSupported, ready, reset, skip
public static final String defaultContinuationChars
public static final String defaultJoinString
public LineFilterReader(Reader in, StringProcessor strategy)
in
- the underlying Reader to filterstrategy
- the StringProcessor used to process each linepublic void setContinuationChars(String chars)
chars
- the continuation chracters to use.public void setJoinString(String str)
str
- the join String to use.public int read() throws IOException
read
in class FilterReader
IOException
- if an I/O error occurs.public int read(char[] cbuf, int off, int len) throws IOException
read
in class FilterReader
cbuf
- destination bufferoff
- offset at which to start storing characterslen
- maximum number of characters to readIOException
- if an I/O error occurs.NullPointerException
- if the destination buffer is nullArrayIndexOutOfBoundsException
- if the offset is out of boundspublic static void processFile(String inputFile, StringProcessor strategy) throws IOException, FileNotFoundException
inputFile
- the file to process.strategy
- StringProcessor to use for processing each line.IOException
- if an I/O error occurs.FileNotFoundException
- if the inputFile cannot be found.public static void processFile(String inputFile, String outputFile, StringProcessor strategy) throws IOException, FileNotFoundException
inputFile
- the file to process.outputFile
- the file to save changes into.strategy
- StringProcessor to use for processing each line.IOException
- if an I/O error occurs.FileNotFoundException
- if the inputFile cannot be found.Copyright © 2023. All rights reserved.