Class LineDemarcator

java.lang.Object
org.apache.nifi.stream.io.util.AbstractTextDemarcator
org.apache.nifi.stream.io.util.LineDemarcator
All Implemented Interfaces:
Closeable, AutoCloseable

public class LineDemarcator extends AbstractTextDemarcator
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\r
  • XYZ\n
  • ABCXYZ\r\n
  • hello
All subsequent calls to nextLine() will return null.
  • Field Details

  • Constructor Details

    • LineDemarcator

      public LineDemarcator(InputStream in, Charset charset, int maxDataSize, int initialBufferSize)
    • LineDemarcator

      public LineDemarcator(Reader reader, int maxDataSize, int initialBufferSize)
  • Method Details

    • nextLine

      public String nextLine() throws IOException
      Will read the next line of text from the InputStream returning null when it reaches the end of the stream.
      Throws:
      IOException - if unable to read from the stream