📜  Java.io.LineNumberReader类

📅  最后修改于: 2020-11-15 02:45:35             🧑  作者: Mango


介绍

Java.io.LineNumberReader类是一个缓冲的字符输入流,用于跟踪行号。行被视为由换行符(’\ n’),回车符(’\ r’ ),或者回车后立即换行。

类声明

以下是Java.io.LineNumberReader类的声明-

public class LineNumberReader
   extends BufferedReader

领域

以下是Java.io.LineNumberReader类的字段-

  • protected Object lock-这是用于同步此流上的操作的对象。

类的构造函数

Sr.No. Constructor & Description
1

LineNumberReader(Reader in)

This creates a new line-numbering reader, using the default input-buffer size.

2

LineNumberReader(Reader in, int sz)

This creates a new line-numbering reader, reading characters into a buffer of the given size.

类方法

Sr.No. Method & Description
1 int getLineNumber()

This method gets the current line number.

2 void mark(int readAheadLimit)

This method mark the present position in the stream.

3 int read()

This method read a single character.

4 int read(char[] cbuf, int off, int len)

This method read characters into a portion of an array.

5 String readLine()

This method read a line of text.

6 void reset()

This method reset the stream to the most recent mark.

7 void setLineNumber(int lineNumber)

This method set the current line number.

8 long skip(long n)

This method skip characters.

方法继承

此类从以下类继承方法-

  • Java.io.BufferedReader
  • Java.io.Reader
  • Java对象