LineNumberReader
A buffered character-input stream that keeps track of line numbers. This class defines methods .setLineNumber and .getLineNumber for setting and getting the current line number respectively.
By default, line numbering begins at 0. This number increments at every #lt as the data is read, and at the end of the stream if the last character in the stream is not a line terminator. This number can be changed with a call to setLineNumber(int). Note however, that setLineNumber(int) does not actually change the current position in the stream; it only changes the value that will be returned by getLineNumber().
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, or any of the previous terminators followed by end of stream, or end of stream not preceded by another terminator.
Author
Mark Reinhold
Since
1.1
Functions
Tells whether this stream supports the mark() operation, which it does.
Read a single character. #lt are compressed into single newline ('\n') characters. The current line number is incremented whenever a line terminator is read, or when the end of the stream is reached and the last character in the stream is not a line terminator.
Reads characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.
Reads characters into a CharBuffer. This default implementation reads into an array and then puts the characters into the buffer.
Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), a carriage return followed immediately by a line feed, or by reaching the end-of-file (EOF).
Read a line of text. #lt are compressed into single newline ('\n') characters. The current line number is incremented whenever a line terminator is read, or when the end of the stream is reached and the last character in the stream is not a line terminator.
Reads all characters from this Reader and writes them to out. Returns the number of characters transferred.