@Override public long readLong() throws IOException { readFully(integralCache.array(), 0, 8); return integralCache.getLong(0); }
@Override public short readShort() throws IOException { readFully(integralCache.array(), 0, 2); return integralCache.getShort(0); }
@Override public int readInt() throws IOException { readFully(integralCache.array(), 0, 4); return integralCache.getInt(0); }
@Test public void testReadResetReadDirectBufferBug() throws IOException { // Make sure we use the exact size of the buffer int size = BufferedImageInputStream.DEFAULT_BUFFER_SIZE; // Fill bytes byte[] bytes = new byte[size * 2]; random.nextBytes(bytes); // Create wrapper stream BufferedImageInputStream stream = new BufferedImageInputStream(new ByteArrayImageInputStream(bytes)); // Read to fill the buffer, then reset stream.readLong(); stream.seek(0); // Read fully and compare byte[] result = new byte[size]; stream.readFully(result); assertTrue(rangeEquals(bytes, 0, result, 0, size)); stream.readFully(result); assertTrue(rangeEquals(bytes, size, result, 0, size)); }
public void testReadResetReadDirectBufferBug() throws IOException { // Make sure we use the exact size of the buffer final int size = BufferedImageInputStream.DEFAULT_BUFFER_SIZE; // Fill bytes byte[] bytes = new byte[size * 2]; mRandom.nextBytes(bytes); // Create wrapper stream BufferedImageInputStream stream = new BufferedImageInputStream(new ByteArrayImageInputStream(bytes)); // Read to fill the buffer, then reset stream.readLong(); stream.seek(0); // Read fully and compare byte[] result = new byte[size]; stream.readFully(result); assertTrue(rangeEquals(bytes, 0, result, 0, size)); stream.readFully(result); assertTrue(rangeEquals(bytes, size, result, 0, size)); }
public void testReadResetReadDirectBufferBug() throws IOException { // Make sure we use the exact size of the buffer final int size = BufferedImageInputStream.DEFAULT_BUFFER_SIZE; // Fill bytes byte[] bytes = new byte[size * 2]; random.nextBytes(bytes); // Create wrapper stream BufferedImageInputStream stream = new BufferedImageInputStream(new ByteArrayImageInputStream(bytes)); // Read to fill the buffer, then reset stream.readLong(); stream.seek(0); // Read fully and compare byte[] result = new byte[size]; stream.readFully(result); assertTrue(rangeEquals(bytes, 0, result, 0, size)); stream.readFully(result); assertTrue(rangeEquals(bytes, size, result, 0, size)); }