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

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
This code example shows how to use the following methods:close
		return channel.isOpen();
	} 
 
	@Override 
	public void close() throws IOException {
		channel.close();
	} 
 
	@Override 
	public int write( ByteBuffer src ) throws IOException {
		return channel.write( src );
	} 
 
	@Override 
	public boolean isNeedWrite() { 
		return channel instanceof WrappedByteChannel ? ( (WrappedByteChannel) channel ).isNeedWrite() : false;
	} 
 
	@Override 
	public void writeMore() throws IOException {
5
CodeRank
This code example shows how to use the following methods:write
 
	public abstract String buildHandShake();
 
} 
5
CodeRank
This code example shows how to use the following methods:read
	{ 
		if (buffer == null) {
			buffer = bufferFactory.newBuffer();
		} 
 
		return channel.read (buffer);
	} 
 
	// -- not needed by framework 
 
	public synchronized boolean isEmpty() 
	{ 
		return (buffer == null) || (buffer.position () == 0);
	} 
 
	public synchronized int indexOf (byte b)
	{ 
		if (buffer == null) {
			return -1; 
		} 
4
CodeRank
This code example shows how to use the following methods:isOpen
		return innerChannel.read(dst);
	} 
 
	@Override 
	public boolean isOpen() { 
		return this.innerChannel.isOpen();
	} 
 
	@Override 
	public void close() throws IOException { 
		this.innerChannel.close();
	} 
 
	@Override 
	public int write(ByteBuffer src) throws IOException {
//		int bytesToBeWritten = src.limit(); 
				//System.out.println("Bytes to be written: " + bytesToBeWritten); 
//		long totalBytesToBeWritten = this.totalBytesWritten + bytesToBeWritten; 
//		if (this.paddedBlocks && totalBytesToBeWritten > this.blockSize){ 
//			//System.out.println("block-total: " + this.blockSize + " - " + totalBytesWritten); 
4
CodeRank
This code example shows how to use the following methods:close
 
    void shutdown() throws IOExceptionfilterChain.sessionClosed( this );
        reader.stop();
        channel.close();
    } 
 
    ByteChannel getChannel()
    { 
        return channel;
    } 
 
    protected void write0(WriteRequest writeRequest)
    { 
        filterChain.filterWrite(this, writeRequest);
    } 
 
    protected void close0() 
    { 
4
CodeRank
This code example shows how to use the following methods:close
    protected synchronized void stopDevice() throws DriverException { 
        getDevice().unregisterAPI(PointerAPI.class); 
        stopDispatcher(); 
 
        try { 
            channel.close();
            channel = null;
        } catch (IOException ex) {
            System.err.println("Error closing Pointer channel: " + ex.toString());
        } 
    } 
 
    /** 
     * Send a given pointer event to the given listener. 
     * 
     * @param listener the pointer listener to recieve the event 
     * @param event    the pointer event 
     */ 
    @Override 
    protected void sendEvent(SystemListener listener, PointerEvent event) {
3
CodeRank
This code example shows how to use the following methods:isOpen
		return channel.read( dst );
	} 
 
	@Override 
	public boolean isOpen() { 
		return channel.isOpen();
	} 
 
	@Override 
	public void close() throws IOException { 
		channel.close();
	} 
 
	@Override 
	public int write( ByteBuffer src ) throws IOException {
		return channel.write( src );
	} 
 
	@Override 
	public boolean isNeedWrite() { 
4
CodeRank
This code example shows how to use the following methods:close
        } catch( IOException e){
            // Normal case: the fcgi server close quickly the connection after the end of the out stream 
        } 
         
        try { 
            outputStream.close();
        } catch( IOException e){
            // Normal case: the fcgi server close quickly the connection after the end of the out stream 
        } 
         
         
    } 
 
    @Override 
    public void write(final byte[] b, final int off, final int len) throws IOException {
 
        if (waitOffset + len < WAIT_BUFFER_SIZE) {
            System.arraycopy(b, off, waitBuffer, waitOffset, len);
            waitOffset += len;
            return; 
4
CodeRank
This code example shows how to use the following methods:close
		return channel.isOpen();
	} 
 
	@Override 
	public void close() throws IOException {
		channel.close();
	} 
 
	@Override 
	public int write( ByteBuffer src ) throws IOException {
		return channel.write( src );
	} 
 
	@Override 
	public boolean isNeedWrite() { 
		return channel instanceof WrappedByteChannel ? ( (WrappedByteChannel) channel ).isNeedWrite() : false;
	} 
 
	@Override 
	public void writeMore() throws IOException {
3
CodeRank
See Code Examples for Java 8 ByteChannel Methods: