Java tutorial
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()); } }