Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## groovy.io
[Java] Class LineColumnReader

    java.lang.Object
      java.io.Reader
          java.io.BufferedReader
              groovy.io.LineColumnReader

    public class LineColumnReader
    extends java.io.BufferedReader

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

Authors:
  Guillaume Laforge

Since:
  1.8.0

Constructor Summary
`LineColumnReader(java.io.Reader reader)` Constructor wrapping a `Reader` (`FileReader`, `FileReader`, `InputStreamReader`, etc.)

Method Summary
`void` | `close()` Closes the stream and releases any system resources associated with it.
`long` | `getColumn()`
`long` | `getColumnMark()`
`long` | `getLine()`
`long` | `getLineMark()`
`void` | `mark(int readAheadLimit)` Marks the present position in the stream.
`int` | `read()` Reads a single character.
`int` | `read(char[] chars, int startOffset, int length)` Reads characters into a portion of an array.
`int` | `read(char[] chars)` Reads characters into an array.
`int` | `read(java.nio.CharBuffer buffer)` Not implemented.
`java.lang.String` | `readLine()` Reads a line of text.
`void` | `reset()` Resets the stream to the most recent mark.
`void` | `setColumn(long column)`
`void` | `setColumnMark(long columnMark)`
`void` | `setLine(long line)`
`void` | `setLineMark(long lineMark)`
`long` | `skip(long toSkip)` Skips characters.

Methods inherited from class java.io.BufferedReader
java.io.BufferedReader#readLine(), java.io.BufferedReader#close(), java.io.BufferedReader#mark(int), java.io.BufferedReader#reset(), java.io.BufferedReader#skip(long), java.io.BufferedReader#read(), java.io.BufferedReader#read([C, int, int), java.io.BufferedReader#markSupported(), java.io.BufferedReader#ready(), java.io.BufferedReader#read(java.nio.CharBuffer), java.io.BufferedReader#read([C), java.io.BufferedReader#wait(long), java.io.BufferedReader#wait(long, int), java.io.BufferedReader#wait(), java.io.BufferedReader#equals(java.lang.Object), java.io.BufferedReader#toString(), java.io.BufferedReader#hashCode(), java.io.BufferedReader#getClass(), java.io.BufferedReader#notify(), java.io.BufferedReader#notifyAll()

Methods inherited from class java.io.Reader
java.io.Reader#close(), java.io.Reader#mark(int), java.io.Reader#reset(), java.io.Reader#skip(long), java.io.Reader#read(java.nio.CharBuffer), java.io.Reader#read(), java.io.Reader#read([C), java.io.Reader#read([C, int, int), java.io.Reader#markSupported(), java.io.Reader#ready(), java.io.Reader#wait(long), java.io.Reader#wait(long, int), java.io.Reader#wait(), java.io.Reader#equals(java.lang.Object), java.io.Reader#toString(), java.io.Reader#hashCode(), java.io.Reader#getClass(), java.io.Reader#notify(), java.io.Reader#notifyAll()

Constructor Detail

### LineColumnReader

    public LineColumnReader(java.io.Reader reader)

  Constructor wrapping a `Reader` (`FileReader`, `FileReader`, `InputStreamReader`, etc.)
  Parameters:
    `reader` - the reader to wrap

Method Detail

### close

    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.

### getColumn

    public long getColumn()

### getColumnMark

    public long getColumnMark()

### getLine

    public long getLine()

### getLineMark

    public long getLineMark()

### mark

    @Override
    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.

### read

    @Override
    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

### read

    if (readInt == -1) return i - startOffset;
    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

### read

    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

### read

    public int read(java.nio.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

### readLine

    int intRead = read();
    public java.lang.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

### reset

    @Override
    public void reset()

  Resets the stream to the most recent mark.

### setColumn

    public void setColumn(long column)

### setColumnMark

    public void setColumnMark(long columnMark)

### setLine

    public void setLine(long line)

### setLineMark

    public void setLineMark(long lineMark)

### skip

    if (intRead == -1) return i;
    public long skip(long toSkip)

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

Groovy Documentation