All About Class InputStream in Java


InputStream is an abstract class that is the super class of an input stream of bytes.Applications that need to define a subclass of the InputStream must always provide a method that returns the next byte of input.
InputStream is a flow of data from an input source to the application under execution or reading bytes of data from some kind of data source.

The structure of the class InputStream  is given as:

public abstract class java.io.InputStream extends java.lang.Object{
//constructor
public InputStream();
//the default constructor,this is always called by the subclasses.
//methods
public int available();//returns the number of bytes of input currently available for reading.
public void close();//closes the input source;further read attempt on a closed input will generate
//an IOException.
public synchronized void mark(int readLimit);//places mark at the current point in the input stream 
//that will remain valid until read limit bytes are read.
public boolean markSupported();//returns true if mark/reset supported on this stream.
public abstract int read();//returns an integer representation of the next available byte of input.
public int read(byte b[]);//attempts to read up to b.length bytes into b and returns the actual number
// of the bytes that were successfully read.
public int read(byte b[],int offSet,int length);//attempts to read up to length bytes into b starting 
//at b[offSet] returning the number of bytes successfully read. 
public synchronized void reset();//returns the input pointer to the previously set mark.
public long skip(long l);//skips over l bytes of input and returning the number of bytes skipped.
}
 
In addition,all methods may throw an IOException if an IO error occurs apart from their regular Exceptions.
All About Class InputStream in Java All About Class InputStream in Java Reviewed by Animesh Chatterjee on October 10, 2018 Rating: 5

No comments:

Powered by Blogger.