Class LineReader


  • public final class LineReader
    extends java.lang.Object
    A class for reading lines of text. Provides the same functionality as BufferedReader.readLine() but for all Readable objects, not just instances of Reader.
    Since:
    1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private char[] buf  
      private java.nio.CharBuffer cbuf  
      private LineBuffer lineBuf  
      private java.util.Queue<java.lang.String> lines  
      private java.lang.Readable readable  
      private java.io.Reader reader  
    • Constructor Summary

      Constructors 
      Constructor Description
      LineReader​(java.lang.Readable readable)
      Creates a new instance that will read lines from the given Readable object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String readLine()
      Reads a line of text.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • readable

        private final java.lang.Readable readable
      • reader

        @CheckForNull
        private final java.io.Reader reader
      • cbuf

        private final java.nio.CharBuffer cbuf
      • buf

        private final char[] buf
      • lines

        private final java.util.Queue<java.lang.String> lines
    • Constructor Detail

      • LineReader

        public LineReader​(java.lang.Readable readable)
        Creates a new instance that will read lines from the given Readable object.
    • Method Detail

      • readLine

        @CheckForNull
        public java.lang.String readLine()
                                  throws java.io.IOException
        Reads a line of text. A line is considered to be terminated by any one of a line feed ( '\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed ("\r\n").
        Returns:
        a String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached.
        Throws:
        java.io.IOException - if an I/O error occurs