Java 8 ReadableByteChannel - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ReadableByteChannel class.

This code example shows how to use the following methods:read
      this.channel = channel;
    } 
     
    @Override 
    int performIO(ByteBuffer buf) throws IOException {
      return channel.read(buf);
    } 
  } 
   
  /** 
   * Create a new input stream with the given timeout. If the timeout 
   * is zero, it will be treated as infinite timeout. The socket's 
   * channel will be configured to be non-blocking. 
   *  
   * @param channel  
   *        Channel for reading, should also be a {@link SelectableChannel}. 
   *        The channel will be configured to be non-blocking. 
   * @param timeout timeout in milliseconds. must not be negative. 
   * @throws IOException 
   */ 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:isOpen, read
    public boolean isEndOfInput() throws Exception {
        if (byteBuffer.position() > 0) {
            // A previous read was not over, so there is a next chunk in the buffer at least 
            return false; 
        } 
        if (in.isOpen()) {
            // Try to read a new part, and keep this part (no rewind) 
            int b = in.read(byteBuffer);
            if (b < 0) {
                return true; 
            } else { 
                offset += b;
                return false; 
            } 
        } 
        return true; 
    } 
 
    @Override 
    public void close() throws Exception {
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close, read
        super.close(); 
        if (LOG.isDebugEnabled()) 
            LOG.debug("close {}", this);
        try 
        { 
            _channel.close();
        } 
        catch (IOException e)
        { 
            LOG.debug(e);
        } 
        finally 
        { 
            _ishut=true;
            _oshut=true;
        } 
    } 
 
    @Override 
    public int fill(ByteBuffer buffer) throws IOException

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:read
 
		_readableByteChannel = readableByteChannel;
 
		_byteBuffer = ByteBuffer.allocate(bufferLength);
 
		if (_readableByteChannel.read(_byteBuffer) == -1) {
			_eof = true;
		} 
		else { 
			_eof = false;
		} 
 
		_byteBuffer.flip();
	} 
 
	public void ensureData(int length) throws IOException {
		if (_byteBuffer.remaining() < length) {
			read(length);
 
			if (_eof || (_byteBuffer.remaining() < length)) {
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:isOpen, read
   } 
 
   @Override 
   public int read(ByteBuffer dst) throws IOException {
      checkOpen(); 
      return delegate.read(dst);
   } 
 
   public long position() throws IOException {
      checkOpen(); 
      return gridInputStream.position();
   } 
 
   public void position(long newPosition) throws IOException {
      checkOpen(); 
      gridInputStream.position(newPosition);
   } 
 
   @Override 
   public boolean isOpen() { 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close, read
    public void produceContent( 
            final ContentEncoder encoder, final IOControl ioctrl) throws IOException {
        if (this.channel == null) {
            this.channel = Channels.newChannel(this.entity.getContent());
        } 
        final int i = this.channel.read(this.buffer);
        this.buffer.flip();
        encoder.write(this.buffer);
        final boolean buffering = this.buffer.hasRemaining();
        this.buffer.compact();
        if (i == -1 && !buffering) {
            encoder.complete();
            close(); 
        } 
    } 
 
    public boolean isRepeatable() { 
        return this.entity.isRepeatable();
    } 
 

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close, isOpen
	public void close() throws IOException {
	    if(buffer != null) {
	        NIOUtilities.clean(buffer); // will close if a MappedByteBuffer
	        buffer = null;
	    } 
		if (channel.isOpen()) {
			channel.close();
		} 
	} 
 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:read
      this.channel = channel;
    } 
     
    @Override 
    int performIO(ByteBuffer buf) throws IOException {
      return channel.read(buf);
    } 
  } 
   
  /** 
   * Create a new input stream with the given timeout. If the timeout 
   * is zero, it will be treated as infinite timeout. The socket's 
   * channel will be configured to be non-blocking. 
   *  
   * @param channel  
   *        Channel for reading, should also be a {@link SelectableChannel}. 
   *        The channel will be configured to be non-blocking. 
   * @param timeout timeout in milliseconds. must not be negative. 
   * @throws IOException 
   */ 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close, read
    } 
 
    public void produceContent( 
            final ContentEncoder encoder,
            final IOControl ioctrl) throws IOException {
        int i = this.channel.read(this.buffer);
        this.buffer.flip();
        encoder.write(this.buffer);
        boolean buffering = this.buffer.hasRemaining();
        this.buffer.compact();
        if (i == -1 && !buffering) {
            encoder.complete();
            this.channel.close();
        } 
    } 
 
    public void finish() { 
        try { 
            this.channel.close();
        } catch (IOException ignore) {
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:read
      this.in = Channels.newChannel(in);
    } 
 
    @Override 
    public int read(ByteBuffer bb) throws IOException {
      return in.read(bb);
    } 
 
    @Override 
    public void close() throws IOException {
      isOpen = false;
      in.close();
    } 
 
    @Override 
    public boolean isOpen() { 
      return isOpen;
    } 
 
  } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Java 8 ReadableByteChannel Questions & Answers:

See Code Examples for Java 8 ReadableByteChannel Methods: