Code example for ByteArrayInputStream

import static; 
public class MarkableInputStreamTest { 
  public void test() throws Exception { 
    MarkableInputStream in = new MarkableInputStream(new ByteArrayInputStream(
    assertThat(readBytes(in, 3)).isEqualTo("ABC");
    long posA = in.savePosition(7);// DEFGHIJ
    assertThat(readBytes(in, 4)).isEqualTo("DEFG");
    in.mark(5); // HIJKL
    assertThat(readBytes(in, 4)).isEqualTo("HIJK");
    in.reset(); // Back to 'H'
    assertThat(readBytes(in, 3)).isEqualTo("HIJ");
    in.reset(posA); // Back to 'D'
    assertThat(readBytes(in, 7)).isEqualTo("DEFGHIJ");
    in.reset(); // Back to 'H' again.
    assertThat(readBytes(in, 6)).isEqualTo("HIJKLM");
    try { 
Experience pair programming with AI  Get Codota for Java