/** * Read the first byte from the wrapped {@link ByteBuffer}. */ @Override public int read() throws IOException { if (!byteBuffer.hasRemaining()){ byteBuffer.clear(); int eof = doRead(); if (eof <= 0){ return -1; } } return (byteBuffer.hasRemaining() ? (byteBuffer.get () & 0xff): -1); }
/** * Read the first byte from the wrapped {@link ByteBuffer}. */ @Override public int read() throws IOException { if (!byteBuffer.hasRemaining()){ byteBuffer.clear(); int eof = doRead(); if (eof <= 0){ return -1; } } return (byteBuffer.hasRemaining() ? (byteBuffer.get () & 0xff): -1); }
/** * Read the first byte from the wrapped {@link ByteBuffer}. */ @Override public int read() throws IOException { if (!byteBuffer.hasRemaining()){ byteBuffer.clear(); int eof = doRead(); if (eof <= 0){ return -1; } } return (byteBuffer.hasRemaining() ? (byteBuffer.get () & 0xff): -1); }
/** * Read the bytes of the wrapped {@link ByteBuffer}. * @param bb {@link ByteBuffer} * @return - number of bytes read * @throws java.io.IOException */ public int read(ByteBuffer bb) throws IOException { //Switch Buffer ByteBuffer oldBB = byteBuffer; byteBuffer = bb; int initialPosition = bb.position(); int eof = doRead(); if (eof <= 0){ return -1; } // Back to the default one. byteBuffer = oldBB; // Calculate the number of bytes were read int bytesRead = bb.limit() - initialPosition; return bytesRead; }
/** * Read the bytes of the wrapped {@link ByteBuffer}. * @param bb {@link ByteBuffer} * @return - number of bytes read * @throws java.io.IOException */ public int read(ByteBuffer bb) throws IOException { //Switch Buffer ByteBuffer oldBB = byteBuffer; byteBuffer = bb; int initialPosition = bb.position(); int eof = doRead(); if (eof <= 0){ return -1; } // Back to the default one. byteBuffer = oldBB; // Calculate the number of bytes were read int bytesRead = bb.limit() - initialPosition; return bytesRead; }
/** * Read the bytes of the wrapped {@link ByteBuffer}. * @param bb {@link ByteBuffer} * @return - number of bytes read * @throws java.io.IOException */ public int read(ByteBuffer bb) throws IOException { //Switch Buffer ByteBuffer oldBB = byteBuffer; byteBuffer = bb; int initialPosition = bb.position(); int eof = doRead(); if (eof <= 0){ return -1; } // Back to the default one. byteBuffer = oldBB; // Calculate the number of bytes were read int bytesRead = bb.limit() - initialPosition; return bytesRead; }
/** * Read the first byte of the wrapped {@link ByteBuffer}. * @param offset * @param length */ @Override public int read(byte[] b, int offset, int length) throws IOException { if (!byteBuffer.hasRemaining()) { byteBuffer.clear(); int eof = doRead(); if (eof <= 0){ return -1; } } if (length > byteBuffer.remaining()) { length = byteBuffer.remaining(); } byteBuffer.get(b, offset, length); return (length); }
/** * Read the first byte of the wrapped {@link ByteBuffer}. * @param offset * @param length */ @Override public int read(byte[] b, int offset, int length) throws IOException { if (!byteBuffer.hasRemaining()) { byteBuffer.clear(); int eof = doRead(); if (eof <= 0){ return -1; } } if (length > byteBuffer.remaining()) { length = byteBuffer.remaining(); } byteBuffer.get(b, offset, length); return (length); }
/** * Read the first byte of the wrapped {@link ByteBuffer}. * @param offset * @param length */ @Override public int read(byte[] b, int offset, int length) throws IOException { if (!byteBuffer.hasRemaining()) { byteBuffer.clear(); int eof = doRead(); if (eof <= 0){ return -1; } } if (length > byteBuffer.remaining()) { length = byteBuffer.remaining(); } byteBuffer.get(b, offset, length); return (length); }