BufferInputStream extends InputStream { public int read() { if (buf.hasRemaining()) { return buf.get() & 0xFF; } else { return -1; } } BufferInputStream(
            @NotNull
            final Buffer buf); int read(); int read(
            @NotNull
            final byte[] bytes,
            final int off,
            final int len);  }
@Test public void readByte() throws IOException { final InputStream is = new BufferInputStream(Buffer.from(DATA)); for (final byte aDATA : DATA) assertEquals(aDATA, is.read()); assertEquals(-1, is.read()); }
@Test public void readBuffer() throws IOException { final InputStream is = new BufferInputStream(Buffer.from(DATA)); final byte[] buf = new byte[DATA.length]; assertEquals(buf.length, is.read(buf)); assertArrayEquals(DATA, buf); assertEquals(-1, is.read(buf)); }