### Question:
ByteArrayWrapper extends ByteArrayInputStream implements PositionedReadable, Seekable, Closeable { public synchronized int read(long position, byte[] buffer, int offset, int length) throws IOException { long oldPos = getPos(); int nread = -1; try { seek(position); nread = read(buffer, offset, length); } finally { seek(oldPos); } return nread; } ByteArrayWrapper(byte[] buf); synchronized void seek(long position); synchronized long getPos(); boolean seekToNewSource(long targetPos); synchronized int read(long position, byte[] buffer, int offset, int length); synchronized void readFully(long position, byte[] buffer, int offset, int length); synchronized void readFully(long position, byte[] buffer);  }### Answer:
@Test public void testRead() throws IOException { byte[] array = createByteArray(16); ByteArrayWrapper wrapper = new ByteArrayWrapper(array); final long oldPosition = wrapper.getPos(); final long newPosition = 3; final int length = 4; byte[] buffer = new byte[length]; int read = wrapper.read(newPosition, buffer, 0, length); assertEquals(length, read); compareByteArrays(array, buffer, (int) newPosition); assertEquals(oldPosition, wrapper.getPos()); wrapper.close(); }