InputStream.reset

InputStream.reset

Class Overview | Class Members | This Package | All Packages

Syntax
public synchronized void reset() throws IOException
Description
Repositions this stream to the position at the time the 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.

Exceptions
IOException if this stream has not been marked or if the mark has been invalidated.
See Also
mark, IOException