LineNumberInputStream 

Introduction

The Java.io.LineNumberInputStream class is an input stream filter that provides the added functionality of keeping track of the current line number. A line is a sequence of bytes ending with a carriage return character (‘\r’), a newline character (‘\n’), or a carriage return character followed immediately by a linefeed character.

Class declaration

Following is the declaration for Java.io.LineNumberInputStream class −

public class LineNumberInputStream
   extends Reader

Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career.

Field

Following are the fields for Java.io.LineNumberInputStream class −

  • protected InputStream in − This is the input stream to be filtered.

Class constructors

Sr.No.Constructor & Description
1LineNumberInputStream(InputStream in)This constructs a newline number input stream that reads its input from the specified input stream.

Class methods

Sr.No.Method & Description
1int available()This method returns the number of bytes that can be read from this input stream without blocking.
2int getLineNumber()This method returns the current line number.
3void mark(int readlimit)This method marks the current position in this input stream.
4int read()This method reads the next byte of data from this input stream.
5int read(byte[] b, int off, int len)This method reads up to len bytes of data from this input stream into an array of bytes.
6void reset()This method repositions this stream to the position at the time the mark method was last called on this input stream.
7void setLineNumber(int lineNumber)This method sets the line number to the specified argument.
8long skip(long n)This method skips over and discards n bytes of data from this input stream.

Methods inherited

This class inherits methods from the following classes −

  • Java.io.FilterInputStream
  • Java.io.Object

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *