Java BufferedInputStream.reset()
Syntax
BufferedInputStream.reset() has the following syntax.
public void reset() throws IOException
Example
In the following code shows how to use BufferedInputStream.reset() method.
/* w ww . j a v a 2 s .c o m*/
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
public class Main {
public static void main(String[] args) throws Exception {
InputStream iStream = new FileInputStream("c:/test.txt");
// input stream converted to buffered input stream
BufferedInputStream bis = new BufferedInputStream(iStream);
// read and print characters one by one
System.out.println((char) bis.read());
System.out.println((char) bis.read());
System.out.println((char) bis.read());
// mark is set on the input stream
bis.mark(0);
System.out.println((char) bis.read());
System.out.println("reset() invoked");
// reset is called
bis.reset();
// read and print characters
System.out.println((char) bis.read());
System.out.println((char) bis.read());
}
}
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »