InputStream.reset() has the following syntax.
public void reset() throws IOException
In the following code shows how to use InputStream.reset() method.
//www .j a v a 2s. c o m import java.io.FileInputStream; import java.io.InputStream; public class Main { public static void main(String[] args) throws Exception { InputStream is = new FileInputStream("C://test.txt"); System.out.println("Characters printed:"); // create new buffered reader // reads and prints BufferedReader System.out.println((char) is.read()); System.out.println((char) is.read()); // mark invoked at this position is.mark(0); System.out.println("mark() invoked"); System.out.println((char) is.read()); System.out.println((char) is.read()); // reset() repositioned the stream to the mark if (is.markSupported()) { is.reset(); System.out.println("reset() invoked"); System.out.println((char) is.read()); System.out.println((char) is.read()); } else { System.out.print("InputStream does not support reset()"); } is.close(); } }