### Question:
DelimiterRangeInputStream extends InputStream { @Override public synchronized void reset() throws IOException { throw new UnsupportedOperationException(); } DelimiterRangeInputStream(
            InputStream stream,
            char delimiter,
            long length,
            boolean skipFirst); @Override int read(); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len); @Override long skip(long n); @Override int available(); @Override synchronized void mark(int readlimit); @Override synchronized void reset(); @Override boolean markSupported(); @Override void close();  }### Answer:
@Test public void readByte_random() throws Exception { byte[] bytes = "ABC|D|EF".getBytes(StandardCharsets.US_ASCII); InputBuffer buffer = new InputBuffer(); buffer.reset(bytes, bytes.length); Random random = new Random(12345); for (int i = 0; i < 100000; i++) { int[] bounds = new int[5]; for (int j = 0; j < bounds.length; j++) { bounds[j] = random.nextInt(bytes.length + 1); } Arrays.sort(bounds); StringBuilder buf = new StringBuilder(); int start = 0; for (int j = 0; j < bounds.length; j++) { int end = bounds[j]; copy(buffer, buf, start, end); start = end; } copy(buffer, buf, start, bytes.length); assertThat(Arrays.toString(bounds), buf.toString(), is("ABC|D|EF")); } }
@Test public void readArray_random() throws Exception { byte[] bytes = "ABC|D|EF".getBytes(StandardCharsets.US_ASCII); InputBuffer buffer = new InputBuffer(); buffer.reset(bytes, bytes.length); Random random = new Random(12345); for (int i = 0; i < 100000; i++) { int[] bounds = new int[5]; for (int j = 0; j < bounds.length; j++) { bounds[j] = random.nextInt(bytes.length + 1); } Arrays.sort(bounds); StringBuilder buf = new StringBuilder(); int start = 0; for (int j = 0; j < bounds.length; j++) { int end = bounds[j]; copy(buffer, buf, start, end, 4); start = end; } copy(buffer, buf, start, bytes.length, 4); assertThat(Arrays.toString(bounds), buf.toString(), is("ABC|D|EF")); } }