class ByteBufferInputStream extends InputStream {

    @Override
    public int read() throws IOException {
        if (bb.remaining() == 0) {
            return -1;
        }
        return bb.get() & 0xff;
    }

    public  ByteBufferInputStream(ByteBuffer bb);

}