Class LineReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public abstract class LineReader
    extends java.lang.Object
    implements java.io.Closeable
    Reads lines of text from an input stream.
    Since:
    28 Apr 2020
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected LineReader​(java.io.InputStream in)
      Constructor.
    • Constructor Detail

      • LineReader

        protected LineReader​(java.io.InputStream in)
        Constructor.
        Parameters:
        in - underlying input stream
    • Method Detail

      • readLine

        public abstract java.lang.String readLine()
                                           throws java.io.IOException
        Returns the next non-empty line of text from the input stream. The line will not consist of only whitespace.
        Returns:
        non-blank line, or null if the input is at an end
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • createAsciiLineReader

        public static LineReader createAsciiLineReader​(java.io.InputStream in)
        Returns a LineReader instance that just uses the lower 7 bits of each input byte for character values.
        Parameters:
        in - input stream
        Returns:
        line reader
      • createArrayLineReader

        public static LineReader createArrayLineReader​(java.lang.String[] lines)
        Returns a LineReader instance that reads lines from an array.
        Parameters:
        lines - line array
        Returns:
        line reader