public final class LineUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
LineUtil.LineAndColumnTracker
Keeps track of "line numbers" and "column numbers" while it
consumes a stream of chars. |
| Modifier and Type | Method and Description |
|---|---|
static LineUtil.LineAndColumnTracker |
lineAndColumnTracker()
Creates a
LineUtil.LineAndColumnTracker which implements line and column counting. |
static Consumer<String> |
lineConsumer(PrintStream ps)
Prints the consumed strings as lines to the given
PrintStream. |
static <T extends CharSequence> |
lineConsumer(PrintWriter pw)
Prints the consumed strings as lines to the given
PrintWriter. |
static ConsumerWhichThrows<String,IOException> |
lineConsumer(Writer w)
Writes the consumed strings as lines to the given
Writer. |
static ConsumerWhichThrows<String,IOException> |
lineConsumerISO8859_1(OutputStream out)
Writes the consumed strings as lines to the ISO 8859-1-encoded
OutputStream. |
static Producer<CharSequence> |
lineProducer(CharSequence text)
Produces lines from a CharSequence by splitting that at line breaks.
|
static ProducerWhichThrows<String,IOException> |
lineProducer(Reader r)
Produces lines from a
Reader. |
static Producer<String> |
lineProducer(String text)
Produces lines from a string by splitting that at line breaks.
|
static ProducerWhichThrows<String,IOException> |
lineProducerISO8859_1(InputStream in)
Produces lines from a ISO 8859-1-encoded
InputStream. |
static List<String> |
readAllLines(Reader r,
boolean closeReader)
Reads lines from the given reader until end-of-input.
|
static ProducerWhichThrows<String,IOException> |
readLineWithSeparator(Reader r)
Similar to
BufferedReader.readLine(), except that
The produced strings include the line separator
Not only CR, LF and CRLF are recognized as line terminators, but also some other special characters, as
described here
|
public static ProducerWhichThrows<String,IOException> lineProducerISO8859_1(InputStream in)
InputStream.public static ProducerWhichThrows<String,IOException> lineProducer(Reader r)
Reader.public static Producer<String> lineProducer(String text)
public static Producer<CharSequence> lineProducer(CharSequence text)
public static ProducerWhichThrows<String,IOException> readLineWithSeparator(Reader r)
BufferedReader.readLine(), except that
r - The source of charactersnull at end-of-inputpublic static ConsumerWhichThrows<String,IOException> lineConsumerISO8859_1(OutputStream out)
OutputStream.public static ConsumerWhichThrows<String,IOException> lineConsumer(Writer w)
Writer.public static <T extends CharSequence> Consumer<T> lineConsumer(PrintWriter pw)
PrintWriter.public static Consumer<String> lineConsumer(PrintStream ps)
PrintStream.public static List<String> readAllLines(Reader r, boolean closeReader) throws IOException
IOExceptionpublic static LineUtil.LineAndColumnTracker lineAndColumnTracker()
LineUtil.LineAndColumnTracker which implements line and column counting.
Line breaks are identified as defined by the \R pattern of Pattern.
Initially, line number and column number are both 1. Line breaks increment the line and reset the column to 1.
TAB characters increase the column to the nearest multiple of the TAB width. All other characters increment the column.
Copyright © 2022 Arno Unkrig. All rights reserved.