### Question:
InputBytes extends ByteArrayInputStream implements Input { @Override public synchronized int read(long pos, byte[] b, int start, int len) throws IOException { this.pos = (int) pos; return read(b, start, len); } InputBytes(byte[] data);  InputBytes(ByteBuffer data); @Override long length(); @Override synchronized int read(long pos, byte[] b, int start, int len);  }### Answer:
@Test public void testRandomReads() throws Exception { Random random = new Random(19820210); int length = random.nextInt(SIZE) + 1; byte[] data = new byte[length]; random.nextBytes(data); Input in = new InputBytes(data); for (int i = 0; i < COUNT; i++) { int p = random.nextInt(length); int l = Math.min(random.nextInt(SIZE / 10), length - p); byte[] buffer = new byte[l]; in.read(p, buffer, 0, l); Assert.assertArrayEquals(Arrays.copyOfRange(data, p, p + l), buffer); } in.close(); }