Code example for ReadableByteChannel

Methods: isOpenread

0
    public boolean hasNextChunk() throws Exception { 
        if (byteBuffer.position() > 0) {
            // A previous read was not over, so there is a next chunk in the buffer at least 
            return true; 
        } 
        if (in.isOpen()) {
            // Try to read a new part, and keep this part (no rewind) 
            int b = in.read(byteBuffer);
            if (b < 0) {
                return false; 
            } else { 
                offset += b;
                return true; 
            } 
        } 
        return false; 
    } 
 
    public boolean isEndOfInput() throws Exception { 
        return !hasNextChunk(); 
    }