Java 8 Channel - 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 Channel class.

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:isOpen, write
   } 
 
   @Override 
   public int write(ByteBuffer src) throws IOException {
      checkOpen(); 
      return delegate.write(src);
   } 
 
   public void flush() throws IOException {
      gridOutputStream.flush();
   } 
 
   @Override 
   public boolean isOpen() { 
      return delegate.isOpen();
   } 
 
   @Override 
   public void close() throws IOException {
      delegate.close();
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close, isOpen
    public void shutdownOutput() 
    { 
        if (LOG.isDebugEnabled()) 
            LOG.debug("oshut {}", this);
        _oshut = true;
        if (_channel.isOpen())
        { 
            try 
            { 
                if (!_socket.isOutputShutdown())
                    _socket.shutdownOutput();
            } 
            catch (IOException e)
            { 
                LOG.debug(e);
            } 
            finally 
            { 
                if (_ishut)
                { 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close, isOpen
	public void sessionClosed(NextFilter next, IoSession session)
			throws Exception { 
		if (headers.isOpen()) {
			headers.close();
		} 
		if (raw.isOpen()) {
			raw.close();
		} 
		next.sessionClosed(session);
	} 
 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close
 
    public void shutdown() { 
      keepRunning = false;
      this.interrupt();
      try { 
        out.close();
      } catch (IOException e) {
        e.printStackTrace();
      } 
    } 
 
    public void run() { 
      byte[] bytes = new byte[4096];
      ByteBuffer buffer = ByteBuffer.wrap(bytes);
      try { 
        while (keepRunning) {
          int count = in.read(bytes);
          // 0 = nothing read 
          // -1 = EOF 
          if (count <= 0) {
5
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
        } 
 
        public void close() 
            throws IOException 
        { 
            delegate.close();
        } 
 
        public int write( ByteBuffer src )
            throws IOException 
        { 
            ByteBuffer event = src.slice();
            int written = delegate.write( src );
            if ( written > 0 )
            { 
                try 
                { 
                    event.limit( written );
                    completionHandler.fireTransferProgressed( event );
                } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close
public class StreamUtil { 
 
	public static void cleanUp(Channel channel) {
		try { 
			if (channel != null) {
				channel.close();
			} 
		} 
		catch (Exception e) {
			if (_log.isWarnEnabled()) { 
				_log.warn(e.getMessage(), e);
			} 
		} 
	} 
 
	public static void cleanUp(InputStream inputStream) {
		try { 
			if (inputStream != null) {
				inputStream.close();
			} 
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 {
        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
    return delegate.isOpen();
  } 
 
  @Override 
  public void close() throws IOException {
    delegate.close();
  } 
 
  @Override 
  public int read(ByteBuffer dst) throws IOException {
    return delegate.read(dst);
  } 
 
  @Override 
  public int write(ByteBuffer src) throws IOException {
    return delegate.write(src);
  } 
 
  @Override 
  public long position() throws IOException {
5
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Java 8 Channel Questions & Answers:

See Code Examples for Java 8 Channel Methods: