Package groovy.io
Class LineColumnReader
java.lang.Object
java.io.Reader
java.io.BufferedReader
groovy.io.LineColumnReader
- All Implemented Interfaces:
- java.io.Closeable,- java.lang.AutoCloseable,- java.lang.Readable
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.- Since:
- 1.8.0
- 
Field SummaryFields inherited from class java.io.Readerlock
- 
Constructor SummaryConstructors Constructor Description LineColumnReader(java.io.Reader reader)Constructor wrapping aReader(FileReader,FileReader,InputStreamReader, etc.)
- 
Method SummaryModifier and Type Method Description voidclose()Closes the stream and releases any system resources associated with it.longgetColumn()longgetColumnMark()longgetLine()longgetLineMark()voidmark(int readAheadLimit)Marks the present position in the stream.intread()Reads a single character.intread(char[] chars)Reads characters into an array.intread(char[] chars, int startOffset, int length)Reads characters into a portion of an array.intread(java.nio.CharBuffer buffer)Not implemented.java.lang.StringreadLine()Reads a line of text.voidreset()Resets the stream to the most recent mark.voidsetColumn(long column)voidsetColumnMark(long columnMark)voidsetLine(long line)voidsetLineMark(long lineMark)longskip(long toSkip)Skips characters.Methods inherited from class java.io.BufferedReaderlines, markSupported, readyMethods inherited from class java.io.ReadernullReader, transferToMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
- 
Constructor Details- 
LineColumnReaderpublic LineColumnReader(java.io.Reader reader)Constructor wrapping aReader(FileReader,FileReader,InputStreamReader, etc.)- Parameters:
- reader- the reader to wrap
 
 
- 
- 
Method Details- 
markpublic void mark(int readAheadLimit) throws java.io.IOExceptionMarks the present position in the stream. Subsequent calls to reset() will attempt to reposition the stream to this point.- Overrides:
- markin class- java.io.BufferedReader
- 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.
- Throws:
- java.io.IOException
 
- 
resetpublic void reset() throws java.io.IOExceptionResets the stream to the most recent mark.- Overrides:
- resetin class- java.io.BufferedReader
- Throws:
- java.io.IOException
 
- 
readpublic int read() throws java.io.IOExceptionReads a single character.- Overrides:
- readin class- java.io.BufferedReader
- 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
- Throws:
- java.io.IOException
 
- 
readpublic int read(char[] chars, int startOffset, int length) throws java.io.IOExceptionReads characters into a portion of an array.- Overrides:
- readin class- java.io.BufferedReader
- 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
- Throws:
- java.io.IOException
 
- 
readLinepublic java.lang.String readLine() throws java.io.IOExceptionReads 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.- Overrides:
- readLinein class- java.io.BufferedReader
- 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
 
- 
skippublic long skip(long toSkip) throws java.io.IOExceptionSkips characters.- Overrides:
- skipin class- java.io.BufferedReader
- Parameters:
- toSkip- the number of characters to skip
- Returns:
- The number of characters actually skipped
- Throws:
- java.io.IOException
 
- 
readpublic int read(char[] chars) throws java.io.IOExceptionReads 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.- Overrides:
- readin class- java.io.Reader
- Parameters:
- chars- Destination buffer
- Returns:
- The number of characters read, or -1 if the end of the stream has been reached
- Throws:
- java.io.IOException
 
- 
readpublic int read(java.nio.CharBuffer buffer)Not implemented.- Specified by:
- readin interface- java.lang.Readable
- Overrides:
- readin class- java.io.Reader
- Parameters:
- buffer- Destination buffer
- Returns:
- The number of characters read, or -1 if the end of the stream has been reached
- Throws:
- java.lang.UnsupportedOperationException- as the method is not implemented
 
- 
closepublic void close() throws java.io.IOExceptionCloses 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.- Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- java.io.Closeable
- Overrides:
- closein class- java.io.BufferedReader
- Throws:
- java.io.IOException
 
- 
getColumnpublic long getColumn()
- 
setColumnpublic void setColumn(long column)
- 
getColumnMarkpublic long getColumnMark()
- 
setColumnMarkpublic void setColumnMark(long columnMark)
- 
getLinepublic long getLine()
- 
setLinepublic void setLine(long line)
- 
getLineMarkpublic long getLineMark()
- 
setLineMarkpublic void setLineMark(long lineMark)
 
-