Java InputStream Class

Category: Java   Tags: Java, Java File Handling, Java Byte Stream Class, Java InputStream Class

InputStream is an abstract class and also the superclass of all classes representing an input stream of bytes. InputStream has this declaration:

                                    public abstract class InputStream
                                    extends Object
                                    implements Closeable
                                

Methods

public int available() throws IOException
It will return the number of bytes available that can be read or skipped over from this input stream without blocking. Returns 0 when it reaches the end of the input stream.
public void close() throws IOException
Closes this input stream and releases any system resources associated with the stream. Further read attempts will generate an IOException.
public abstract int read() throws IOException
Returns an integer representation (in the range 0 to 255) of the next available byte of input. Returns -1 if the end of the stream is reached.
public int read(byte[] b) throws IOException
It tries to read bytes (up to b.length bytes) into b and returns the actual number of bytes that were successfully read. Returns -1 if the end of the file is reached.
public int read(byte[] b, int offset, int num) throws IOException
It tries to read bytes (up to num bytes) into b starting at b[offset] and returns the actual number of bytes that were successfully read. Returns -1 if the end of the file is reached.
public long skip(long n) throws IOException
It skips n bytes of input, returning the number of bytes actually ignored.
public void mark(int limit)
Marks the current position in this input stream. Returns limit, the maximum limit of bytes that can be read before the mark position becomes invalid.
public void reset() throws IOException
Resets this stream to the previously set mark. Throws IOException if this stream has not been marked or if the mark has been invalidated.
public boolean markSupported()
Returns true if mark() or reset() are supported by the this stream.