Example usage for java.io FilterInputStream reset

List of usage examples for java.io FilterInputStream reset

Introduction

In this page you can find the example usage for java.io FilterInputStream reset.

Prototype

public synchronized void reset() throws IOException 

Source Link

Document

Repositions this stream to the position at the time the mark method was last called on this input stream.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {

    // create input streams
    InputStream is = new FileInputStream("C://test.txt");
    FilterInputStream fis = new BufferedInputStream(is);

    // reads and prints BufferedReader
    System.out.println((char) fis.read());
    System.out.println((char) fis.read());

    // mark invoked at this position
    fis.mark(0);/*from w w w.  j  a  va 2s.  c om*/
    System.out.println("mark() invoked");
    System.out.println((char) fis.read());
    System.out.println((char) fis.read());

    // reset() repositioned the stream to the mark
    fis.reset();
    System.out.println("reset() invoked");
    System.out.println((char) fis.read());
    System.out.println((char) fis.read());

}

From source file:Main.java

public static void main(String[] args) throws Exception {

    // create input streams
    InputStream is = new FileInputStream("C://test.txt");
    FilterInputStream fis = new BufferedInputStream(is);

    // reads and prints filter input stream
    System.out.println((char) fis.read());
    System.out.println((char) fis.read());

    // mark invoked at this position
    fis.mark(0);//from   ww w. j a  v  a2  s  . c o m
    System.out.println("mark() invoked");
    System.out.println((char) fis.read());
    System.out.println((char) fis.read());

    // reset() repositioned the stream to the mark
    fis.reset();
    System.out.println("reset() invoked");
    System.out.println((char) fis.read());
    System.out.println((char) fis.read());

}