RandomAccessData { public void resetTo(int position) { ensureCapacity(position); size = position; } RandomAccessData();  RandomAccessData(byte[] initialBuffer);  RandomAccessData(int initialBufferSize); RandomAccessData increment(); byte[] array(); int size(); void resetTo(int position); OutputStream asOutputStream(); InputStream asInputStream(final int offset, final int length); void writeTo(OutputStream out, int offset, int length); void readFrom(InputStream inStream, int offset, int length); RandomAccessData copy(); @Override boolean equals(@Nullable Object other); @Override int hashCode(); @Override String toString(); static final UnsignedLexicographicalComparator UNSIGNED_LEXICOGRAPHICAL_COMPARATOR; }
@Test public void testResetTo() throws Exception { RandomAccessData stream = new RandomAccessData(); stream.asOutputStream().write(TEST_DATA_A); stream.resetTo(1); assertEquals(1, stream.size()); stream.asOutputStream().write(TEST_DATA_A); assertArrayEquals( new byte[] {0x01, 0x01, 0x02, 0x03}, Arrays.copyOf(stream.array(), stream.size())); }