Example usage for java.io PushbackInputStream reset

List of usage examples for java.io PushbackInputStream reset

Introduction

In this page you can find the example usage for java.io PushbackInputStream 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) {
    byte[] arrByte = new byte[1024];
    byte[] byteArray = new byte[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' };

    InputStream is = new ByteArrayInputStream(byteArray);
    PushbackInputStream pis = new PushbackInputStream(is);

    try {//from   w w w  .  j  a v  a2  s .  c  o m

        for (int i = 0; i < byteArray.length; i++) {

            arrByte[i] = (byte) pis.read();

            System.out.println((char) arrByte[i]);
        }

        pis.reset();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}