Sunday 24 April 2011

The InputStream Class

java.io.InputStream is an abstract class that contains the basic methods for reading raw bytes of data from a stream. Although InputStream is an abstract class, many methods in the class library are only specified to return an InputStream, s o you'll often have to deal directly with only the methods declared in this class.
 public abstract int read() throws IOException

public int read(byte[] data) throws IOException
public int read(byte[] data, int offset, int length)
throws IOException

public long skip(long n) throws IOException
public int available() throws IOException
public void close() throws IOException

public void mark(int readLimit)
public void reset() throws IOException
public boolean markSupported()
Notice that almost all these methods can throw an IOException. This is true of pretty much anything to do with input and output. The only exception is the PrintStream class which eats all exceptions.

No comments:

Post a Comment