All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.io.InputStream
Applications that need to define a subclass of InputStream must always provide a method that returns the next byte of input.
mark and reset methods. b.length bytes of data from this input stream into an array of bytes. len bytes of data from this input stream into an array of bytes. mark method was last called on this input stream. n bytes of data from this input stream. public InputStream()
public abstract int read() throws IOException
int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown. A subclass must provide an implementation of this method.
-1 if the end of the stream is reached. public int read(byte b[]) throws IOException
b.length bytes of data from this input stream into an array of bytes. The read method of InputStream calls the read method of three arguments with the arguments b, 0, and b.length.
-1 is there is no more data because the end of the stream has been reached.
public int read(byte b[],
int off,
int len) throws IOException
len bytes of data from this input stream into an array of bytes. This method blocks until some input is available. If the argument b is null, a NullPointerException is thrown. The read method of InputStream reads a single byte at a time using the read method of zero arguments to fill in the array. Subclasses are encouraged to provide a more efficient implementation of this method.
-1 if there is no more data because the end of the stream has been reached. public long skip(long n) throws IOException
n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned. The skip method of InputStream creates a byte array of length n and then reads into it until n bytes have been read or the end of the stream has been reached. Subclasses are encouraged to provide a more efficient implementation of this method.
public int available() throws IOException
InputStream returns 0. This method should be overridden by subclasses. public void close() throws IOException
The close method of InputStream does nothing.
public synchronized void mark(int readlimit)
reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes. The readlimit arguments tells this input stream to allow that many bytes to be read before the mark position gets invalidated.
The mark method of InputStream does nothing.
public synchronized void reset() throws IOException
mark method was last called on this input stream. The reset method of InputStream throws an IOException, because input streams, by default, do not support mark and reset.
Stream marks are intended to be used in situations where you need to read ahead a little to see what's in the stream. Often this is most easily done by invoking some general parser. If the stream is of the type handled by the parser, it just chugs along happily. If the stream is not of that type, the parser should toss an exception when it fails, which, if it happens within readlimit bytes, allows the outer code to reset the stream and try another parser.
public boolean markSupported()
mark and reset methods. The markSupported method of InputStream returns false. true if this true type supports the mark and reset method; false otherwise. All Packages Class Hierarchy This Package Previous Next Index