@Test public void testRead() throws IOException { ByteBufferInputStream bis = new ByteBufferInputStream(ByteBuffer.wrap(new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9})); for (int x = 0; x < 10; ++x) { assertEquals(10 - x, bis.available()); assertEquals(x, bis.read()); } assertEquals(0, bis.available()); bis.close(); }
@Override public int read() { if (buffer.hasRemaining()) { int tmp = buffer.get(); if (tmp < 0) { tmp += 256; } return tmp; } else { return -1; } }
ByteBufferInputStream extends InputStream { @Override public int read() { if (buffer.hasRemaining()) { int tmp = buffer.get(); if (tmp < 0) { tmp += 256; } return tmp; } else { return -1; } } }
ByteBufferInputStream extends InputStream { @Override public int read() { if (buffer.hasRemaining()) { int tmp = buffer.get(); if (tmp < 0) { tmp += 256; } return tmp; } else { return -1; } } ByteBufferInputStream(ByteBuffer buffer); }
ByteBufferInputStream extends InputStream { @Override public int read() { if (buffer.hasRemaining()) { int tmp = buffer.get(); if (tmp < 0) { tmp += 256; } return tmp; } else { return -1; } } ByteBufferInputStream(ByteBuffer buffer); @Override int read(); @Override int read(byte[] b, int off, int len); @Override int available(); }
ByteBufferInputStream extends InputStream { @Override public int read() { if (buffer.hasRemaining()) { int tmp = buffer.get(); if (tmp < 0) { tmp += 256; } return tmp; } else { return -1; } } ByteBufferInputStream(ByteBuffer buffer); @Override int read(); @Override int read(byte[] b, int off, int len); @Override int available();  }