ByteArrayInputStream dime = new ByteArrayInputStream(new byte[]{
1, 4, 2, 6, 3
});
for(int i = 0; i != -1;){
i = dime.read();
if(i == 4) dime.mark(6);
else if(i == 6) dime.reset();
System.out.print(i + " ");
}
If such an IOException is not thrown, then the stream is reset to a state such that all the bytes read since the most recent call to mark (or since the start of the file, if mark has not been called) will be resupplied to subsequent callers of the read method