Top Description Fields Constructors Methods
groovy.io

public Class LineColumnReader

extends BufferedReader
Class Inheritance
Imports
java.io.BufferedReader, .IOException, .Reader, java.nio.CharBuffer

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

Field Summary

Modifier and TypeField and Description
private long
column

The current column position

private long
columnMark

The latest marked line position

private long
line

The current line position

private long
lineMark

The latest marked line position

private boolean

Constructor Summary

AccessConstructor and Description
public
LineColumnReader(Reader
the reader to wrap
reader
)

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

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.BufferedReader.close.

Implements java.io.Closeable.close.

Closes the stream and releases any system resources associated with it.
public long
public long
public long
public long
public void
mark(int
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.
readAheadLimit
)

Overrides java.io.BufferedReader.mark.

Marks the present position in the stream.
public int

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
()

Overrides java.io.BufferedReader.read.

Reads a single character.
public int

Returns:

an exception if an error occurs
read
(char[]
Destination array of char
chars
,
int
Offset at which to start storing characters
startOffset
,
int
Maximum number of characters to read
length
)

Overrides java.io.BufferedReader.read.

Reads characters into a portion of an array.
public int

Returns:

The number of characters read, or -1 if the end of the stream has been reached
read
(char[]
Destination buffer
chars
)

Overrides java.io.Reader.read.

Reads characters into an array.
public int

Returns:

The number of characters read, or -1 if the end of the stream has been reached
read
(CharBuffer
Destination buffer
buffer
)

Overrides java.io.Reader.read.

Implements java.lang.Readable.read.

Not implemented.
public String

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
readLine
()

Overrides java.io.BufferedReader.readLine.

Reads a line of text.
public void
reset()

Overrides java.io.BufferedReader.reset.

Resets the stream to the most recent mark.
public void
setColumn(long column)

public void
setColumnMark(long columnMark)

public void
setLine(long line)

public void
setLineMark(long lineMark)

public long

Returns:

The number of characters actually skipped
skip
(long
the number of characters to skip
toSkip
)

Overrides java.io.BufferedReader.skip.

Skips characters.
Inherited from java.io.BufferedReader:
linesmarkSupportedready

Field Detail

columnback to summary
private long column

The current column position

columnMarkback to summary
private long columnMark

The latest marked line position

lineback to summary
private long line

The current line position

lineMarkback to summary
private long lineMark

The latest marked line position

newLineWasReadback to summary
private boolean newLineWasRead

Constructor Detail

LineColumnReaderback to summary
public LineColumnReader(Reader reader)

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

Parameters
reader:Reader

the reader to wrap

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.BufferedReader.close.

Implements java.io.Closeable.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.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.Reader.close.

If an I/O error occurs

getColumnback to summary
public long getColumn()
getColumnMarkback to summary
public long getColumnMark()
getLineback to summary
public long getLine()
getLineMarkback to summary
public long getLineMark()
markback to summary
public void mark(int readAheadLimit) throws IOException

Overrides java.io.BufferedReader.mark.

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

Parameters
readAheadLimit:int

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.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.BufferedReader.mark.

If an I/O error occurs

readback to summary
public int read() throws IOException

Overrides java.io.BufferedReader.read.

Reads a single character.

Returns:int

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

Annotations
@Override
Exceptions
IOException:

Doc from java.io.BufferedReader.read.

If an I/O error occurs

readback to summary
public int read(char[] chars, int startOffset, int length) throws IOException

Overrides java.io.BufferedReader.read.

Reads characters into a portion of an array.

Parameters
chars:char[]

Destination array of char

startOffset:int

Offset at which to start storing characters

length:int

Maximum number of characters to read

Returns:int

an exception if an error occurs

Annotations
@Override
Exceptions
IOException:

Doc from java.io.BufferedReader.read.

If an I/O error occurs

readback to summary
public int read(char[] chars) throws IOException

Overrides java.io.Reader.read.

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:char[]

Destination buffer

Returns:int

The number of characters read, or -1 if the end of the stream has been reached

Annotations
@Override
Exceptions
IOException:

Doc from java.io.Reader.read.

If an I/O error occurs

readback to summary
public int read(CharBuffer buffer)

Overrides java.io.Reader.read.

Implements java.lang.Readable.read.

Not implemented.

Parameters
buffer:CharBuffer

Destination buffer

Returns:int

The number of characters read, or -1 if the end of the stream has been reached

Annotations
@Override
Exceptions
UnsupportedOperationException:
as the method is not implemented
readLineback to summary
public String readLine() throws IOException

Overrides java.io.BufferedReader.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:String

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

Annotations
@Override
Exceptions
IOException:

Doc from java.io.BufferedReader.readLine.

If an I/O error occurs

resetback to summary
public void reset() throws IOException

Overrides java.io.BufferedReader.reset.

Resets the stream to the most recent mark.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.BufferedReader.reset.

If the stream has never been marked, or if the mark has been invalidated

setColumnback to summary
public void setColumn(long column)
setColumnMarkback to summary
public void setColumnMark(long columnMark)
setLineback to summary
public void setLine(long line)
setLineMarkback to summary
public void setLineMark(long lineMark)
skipback to summary
public long skip(long toSkip) throws IOException

Overrides java.io.BufferedReader.skip.

Skips characters.

Parameters
toSkip:long

the number of characters to skip

Returns:long

The number of characters actually skipped

Annotations
@Override
Exceptions
IOException:

Doc from java.io.Reader.skip.

If an I/O error occurs