java.io.LineNumberReader
A buffered character-input stream that keeps track of line numbers. This class defines methods setLineNumber(int) and getLineNumber() for setting and getting the current line number respectively.
Note:
1. By default, line numbering begins at 0. This number increments at every line terminator as the data is read and can be changed with a call to setLineNumber(int).
2. 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().
3. 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 line feed.
Some methods of LineNumberReader class
getLineNumber(): This method gets the current line number.
LineNumberReader(Reader): This method creates a new line-numbering reader, using the default input buffer size.
LineNumberReader(Reader, int): This method creates a new line-numbering reader, reading characters into a buffer of the given size.
mark(int): This method marks the present position in the stream.
read(): This method read a single character.
read(char[], int, int): This method read characters into a portion of an array.
readLine(): This method read a line of text.
reset(): This method resets the stream to the most recent mark.
setLineNumber(int): This method sets the current line number.
skip(long): This method skips characters.
No comments:
Post a Comment