Package org.commonmark.internal.util
Class LineReader
java.lang.Object
org.commonmark.internal.util.LineReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
Reads lines from a reader like
BufferedReader
but also returns the line terminators.
Line terminators can be either a line feed "\n"
, carriage return "\r"
, or a carriage return followed
by a line feed "\r\n"
. Call getLineTerminator()
after readLine()
to obtain the
corresponding line terminator. If a stream has a line at the end without a terminator, getLineTerminator()
returns null
.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
private void
fill()
private String
finish
(StringBuilder sb, int start, int end) Return the line terminator of the last read line fromreadLine()
.private String
readLine()
Read a line of text.
-
Field Details
-
CHAR_BUFFER_SIZE
static final int CHAR_BUFFER_SIZE- See Also:
-
EXPECTED_LINE_LENGTH
static final int EXPECTED_LINE_LENGTH- See Also:
-
reader
-
cbuf
private char[] cbuf -
position
private int position -
limit
private int limit -
lineTerminator
-
-
Constructor Details
-
LineReader
-
-
Method Details
-
readLine
Read a line of text.- Returns:
- the line, or
null
when the end of the stream has been reached and no more lines can be read - Throws:
IOException
-
getLineTerminator
Return the line terminator of the last read line fromreadLine()
.- Returns:
"\n"
,"\r"
,"\r\n"
, ornull
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
fill
- Throws:
IOException
-
line
-
finish
-