← 返回首页
LineNumberReader (Java SE 26 & JDK 26)
JavaScript is disabled on your browser.
Contents  
  1. Description
  2. Field Summary
  3. Constructor Summary
  4. Method Summary
  5. Constructor Details
    1. LineNumberReader(Reader)
    2. LineNumberReader(Reader, int)
  6. Method Details
    1. setLineNumber(int)
    2. getLineNumber()
    3. read()
    4. read(char[], int, int)
    5. readLine()
    6. mark(int)
    7. reset()
Hide sidebar  Show sidebar

Class LineNumberReader

All Implemented Interfaces: Closeable, AutoCloseable, Readable
public class LineNumberReader extends BufferedReader
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.

By default, line numbering begins at 0. This number increments at every line terminator 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.

Since: 1.1

Scripting on this page tracks web page traffic, but does not change the content in any way.