Package org.apache.nifi.stream.io.util
Class LineDemarcator
java.lang.Object
org.apache.nifi.stream.io.util.AbstractTextDemarcator
org.apache.nifi.stream.io.util.LineDemarcator
- All Implemented Interfaces:
Closeable,AutoCloseable
A demarcator that scans an InputStream for line endings (carriage returns and new lines) and returns
lines of text one-at-a-time. This is similar to BufferedReader but with a very important distinction: while
BufferedReader returns the lines of text after stripping off any line endings, this class returns text including the
line endings. So, for example, if the following text is provided:
ABC\rXYZ\nABCXYZ\r\nhello
Then calls to nextLine() will result in 4 String values being returned:
ABC\rXYZ\nABCXYZ\r\nhello
nextLine() will return null.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final charprivate charprivate static final charFields inherited from class org.apache.nifi.stream.io.util.AbstractTextDemarcator
availableBytesLength, buffer, index, mark -
Constructor Summary
ConstructorsConstructorDescriptionLineDemarcator(InputStream in, Charset charset, int maxDataSize, int initialBufferSize) LineDemarcator(Reader reader, int maxDataSize, int initialBufferSize) -
Method Summary
Modifier and TypeMethodDescriptionnextLine()Will read the next line of text from theInputStreamreturning null when it reaches the end of the stream.Methods inherited from class org.apache.nifi.stream.io.util.AbstractTextDemarcator
close, fill
-
Field Details
-
CARRIAGE_RETURN
private static final char CARRIAGE_RETURN- See Also:
-
NEW_LINE
private static final char NEW_LINE- See Also:
-
lastChar
private char lastChar
-
-
Constructor Details
-
LineDemarcator
-
LineDemarcator
-
-
Method Details
-
nextLine
Will read the next line of text from theInputStreamreturning null when it reaches the end of the stream.- Throws:
IOException- if unable to read from the stream
-