Class LineReader

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

    public final class LineReader
    extends java.io.BufferedReader
    If extends BufferedReader but provides you the line number in which the reader is reading.
    Since:
    1.4 (13.11.2013)
    Author:
    oliver
    • Field Summary

      • Fields inherited from class java.io.Reader

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      LineReader​(java.io.Reader in)
      Instantiates a new line reader.
      LineReader​(java.io.Reader in, int sz)
      Instantiates a new line reader.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getLineNumber()
      Gets the line number.
      int read()
      Read.
      int read​(char[] arg0, int arg1, int arg2)
      Read.
      java.lang.String readLine()
      Read line.
      void reset()
      Reset.
      long skip​(long arg0)
      Skip.
      void skipLines​(int n)
      Skip lines.
      java.lang.String toString()
      To string.
      • Methods inherited from class java.io.BufferedReader

        close, lines, mark, markSupported, ready
      • Methods inherited from class java.io.Reader

        nullReader, read, read, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • LineReader

        public LineReader​(java.io.Reader in)
        Instantiates a new line reader.
        Parameters:
        in - the in
      • LineReader

        public LineReader​(java.io.Reader in,
                          int sz)
        Instantiates a new line reader.
        Parameters:
        in - the in
        sz - the sz
    • Method Detail

      • getLineNumber

        public int getLineNumber()
        Gets the line number.
        Returns:
        the line number
      • read

        public int read()
                 throws java.io.IOException
        Read.
        Overrides:
        read in class java.io.BufferedReader
        Returns:
        the int
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
        See Also:
        BufferedReader.read()
      • read

        public int read​(char[] arg0,
                        int arg1,
                        int arg2)
                 throws java.io.IOException
        Read.
        Overrides:
        read in class java.io.BufferedReader
        Parameters:
        arg0 - the arg0
        arg1 - the arg1
        arg2 - the arg2
        Returns:
        the int
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
        See Also:
        BufferedReader.read(char[], int, int)
      • readLine

        public java.lang.String readLine()
                                  throws java.io.IOException
        Read line.
        Overrides:
        readLine in class java.io.BufferedReader
        Returns:
        the string
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
        See Also:
        BufferedReader.readLine()
      • reset

        public void reset()
                   throws java.io.IOException
        Reset.
        Overrides:
        reset in class java.io.BufferedReader
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
        See Also:
        BufferedReader.reset()
      • skip

        public long skip​(long arg0)
                  throws java.io.IOException
        Skip.
        Overrides:
        skip in class java.io.BufferedReader
        Parameters:
        arg0 - the arg0
        Returns:
        the long
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
        See Also:
        BufferedReader.skip(long)
      • skipLines

        public void skipLines​(int n)
                       throws java.io.IOException
        Skip lines.
        Parameters:
        n - the number of lines to skip
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • toString

        public java.lang.String toString()
        To string.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the string
        See Also:
        Object.toString()