Package: groovy.io

## [Java] Class LineColumnReader

- groovy.io.LineColumnReader

-     public class LineColumnReader
      extends BufferedReader

  The `LineColumnReader` is an extension to `BufferedReader` that keeps track of the line and column information of where the cursor is.

  Since:
    1.8.0

- - ### Constructor Summary

    Constructors
    Constructor and description
    `LineColumnReader(Reader reader)` Constructor wrapping a `Reader` (`FileReader`, `FileReader`, `InputStreamReader`, etc.)

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `close()` Closes the stream and releases any system resources associated with it.
    `` | `public long` | `getColumn()` Returns the current column number.
    `` | `public long` | `getColumnMark()` Returns the marked column number.
    `` | `public long` | `getLine()` Returns the current line number.
    `` | `public long` | `getLineMark()` Returns the marked line number.
    `` | `public void` | `mark(int readAheadLimit)` Marks the present position in the stream.
    `` | `public int` | `read()` Reads a single character.
    `` | `public int` | `read(char[] chars, int startOffset, int length)` Reads characters into a portion of an array.
    `` | `public int` | `read(char[] chars)` Reads characters into an array.
    `` | `public int` | `read(CharBuffer buffer)` Not implemented.
    `` | `public String` | `readLine()` Reads a line of text.
    `` | `public void` | `reset()` Resets the stream to the most recent mark.
    `` | `public void` | `setColumn(long column)` Sets the current column number.
    `` | `public void` | `setColumnMark(long columnMark)` Sets the marked column number.
    `` | `public void` | `setLine(long line)` Sets the current line number.
    `` | `public void` | `setLineMark(long lineMark)` Sets the marked line number.
    `` | `public long` | `skip(long toSkip)` Skips characters.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class BufferedReader` | `close, equals, getClass, hashCode, lines, mark, markSupported, notify, notifyAll, nullReader, read, read, read, read, readLine, ready, reset, skip, toString, transferTo, wait, wait, wait`

- - ### Constructor Detail

    - #### public LineColumnReader(Reader reader)

      Constructor wrapping a `Reader` (`FileReader`, `FileReader`, `InputStreamReader`, etc.)

      Parameters:
        `reader` - the reader to wrap

  - ### Method Detail

    - #### public void close()

      Closes the stream and releases any system resources associated with it. Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.

    - #### public long getColumn()

      Returns the current column number.

      Returns:
        the current column number

    - #### public long getColumnMark()

      Returns the marked column number.

      Returns:
        the marked column number

    - #### public long getLine()

      Returns the current line number.

      Returns:
        the current line number

    - #### public long getLineMark()

      Returns the marked line number.

      Returns:
        the marked line number

    - #### public void mark(int readAheadLimit)

      Marks the present position in the stream. Subsequent calls to reset() will attempt to reposition the stream to this point.

      Parameters:
        `readAheadLimit` - Limit on the number of characters that may be read while still preserving the mark. An attempt to reset the stream after reading characters up to this limit or beyond may fail. A limit value larger than the size of the input buffer will cause a new buffer to be allocated whose size is no smaller than limit. Therefore large values should be used with care.

    - #### public int read()

      Reads a single character.

      Returns:
        The character read, as an integer in the range 0 to 65535 (0x00-0xffff), or -1 if the end of the stream has been reached

    - #### public int read(char[] chars, int startOffset, int length)

      Reads characters into a portion of an array.

      Parameters:
        `chars` - Destination array of char
        `startOffset` - Offset at which to start storing characters
        `length` - Maximum number of characters to read
      Returns:
        an exception if an error occurs

    - #### public int read(char[] chars)

      Reads characters into an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

      Parameters:
        `chars` - Destination buffer
      Returns:
        The number of characters read, or -1 if the end of the stream has been reached

    - #### public int read(CharBuffer buffer)

      Not implemented.

      throws:
        UnsupportedOperationException as the method is not implemented
      Parameters:
        `buffer` - Destination buffer
      Returns:
        The number of characters read, or -1 if the end of the stream has been reached

    - #### public String readLine()

      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.

      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

    - #### public void reset()

      Resets the stream to the most recent mark.

    - #### public void setColumn(long column)

      Sets the current column number.

      Parameters:
        `column` - the current column number

    - #### public void setColumnMark(long columnMark)

      Sets the marked column number.

      Parameters:
        `columnMark` - the marked column number

    - #### public void setLine(long line)

      Sets the current line number.

      Parameters:
        `line` - the current line number

    - #### public void setLineMark(long lineMark)

      Sets the marked line number.

      Parameters:
        `lineMark` - the marked line number

    - #### public long skip(long toSkip)

      Skips characters.

      Parameters:
        `toSkip` - the number of characters to skip
      Returns:
        The number of characters actually skipped