@Test public void testSingleByteRead() { byte[] expected = "This is a test for single byte read".getBytes(UTF_8); List<byte[]> buffers = ImmutableList.of( "This ".getBytes(UTF_8), "is ".getBytes(UTF_8), "a test ".getBytes(UTF_8), "for".getBytes(UTF_8), " single byte read".getBytes(UTF_8)); byte[] resultBuffer = new byte[expected.length]; try (GatheringByteArrayInputStream in = new GatheringByteArrayInputStream(buffers, expected.length)) { for (int i = 0; i < expected.length; i++) { resultBuffer[i] = (byte) in.read(); } assertByteArrayEquals(resultBuffer, 0, expected, 0, expected.length); assertEquals(in.read(), -1); } }
@Override public synchronized int read(byte[] buffer) { return read(buffer, 0, buffer.length); }
GatheringByteArrayInputStream extends InputStream { @Override public synchronized int read(byte[] buffer) { return read(buffer, 0, buffer.length); } }
GatheringByteArrayInputStream extends InputStream { @Override public synchronized int read(byte[] buffer) { return read(buffer, 0, buffer.length); } GatheringByteArrayInputStream(List<byte[]> buffers, long totalBytes); }
GatheringByteArrayInputStream extends InputStream { @Override public synchronized int read(byte[] buffer) { return read(buffer, 0, buffer.length); } GatheringByteArrayInputStream(List<byte[]> buffers, long totalBytes); @Override synchronized int read(byte[] buffer); @Override synchronized int read(); @Override synchronized long skip(long n); @Override synchronized int read(byte[] buffer, int offset, int length); @Override void close(); }
GatheringByteArrayInputStream extends InputStream { @Override public synchronized int read(byte[] buffer) { return read(buffer, 0, buffer.length); } GatheringByteArrayInputStream(List<byte[]> buffers, long totalBytes); @Override synchronized int read(byte[] buffer); @Override synchronized int read(); @Override synchronized long skip(long n); @Override synchronized int read(byte[] buffer, int offset, int length); @Override void close();  }