All About Class LineNumberInputStream in Java

0
28
Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

LineNumberInputStream in Java
LineNumberInputStream in Java

LineNumberInputStream in Java:

A line is a sequence of bytes ending either a carriage return character(“r”),a new line character(“n”) or a carriage return character followed immediately by a line feed character.In all these cases,the line terminating character(s) are returned as a single newline character.
LineNumberInputStream class is an input stream filter that provides the added functionality of keeping track of the current line number. The line number begins at zero and it is incremented by one when a read returns a newline character.
LineNumberInputStream keeps track of the line numbers in the InputStream. We can call getLineNumber() and setLineNumber() to get a specific line and to work on a line.The constructor takes InputStream as an argument to add line numbering. We need to attach this to an interface object.

The structure of the class LineNumberInputStream is given as:


public class java.io.LineNumberInputStream extends java.io.FilterInputStream{
//constructor
public LineNumberInputStream(InputStream in);
//constructs a new LineNumberInputStream  which reads its input stream.
//methods
public int available();
public int read();
public int read(byte b[],int offSet,int length);
public long skip(long l);
public void mark(int readLimit);
public void reset();
public int getLineNumber();
public void setLineNumber(int lineNumber);
}
 

In addition,all methods may throw an IOException if an IO error occurs apart from their regular Exceptions.

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

LEAVE A REPLY

Please enter your comment!
Please enter your name here