ByteArrayInputStream: reset() : ByteArrayInputStream « java.io « Java by API






ByteArrayInputStream: reset()

 

import java.io.ByteArrayInputStream;
import java.io.IOException;

public class Main {
  public static void main(String args[]) throws IOException {
    String tmp = "abc";
    byte b[] = tmp.getBytes();
    ByteArrayInputStream in = new ByteArrayInputStream(b);

    for (int i = 0; i < 2; i++) {
      int c;
      while ((c = in.read()) != -1) {
        if (i == 0) {
          System.out.print((char) c);
        } else {
          System.out.print(Character.toUpperCase((char) c));
        }
      }
      System.out.println();
      in.reset();
    }
  }
}

   
  








Related examples in the same category

1.new ByteArrayInputStream(byte[] buf)
2.new ByteArrayInputStream(byte[] buf, int offset, int length)
3.ByteArrayInputStream: available()
4.ByteArrayInputStream: read(byte[] b, int off, int len)