Code example for SelectionKey

Methods: isValid

0
        this.key = key;
    } 
 
    public boolean isClosed() { 
        return this.closed || (this.key != null && !this.key.isValid());
    } 
 
    public void close() { 
        if (this.closed) {
            return; 
        } 
        this.completed = true;
        this.closed = true;
        if (this.key != null) {
            this.key.cancel();
            final Channel channel = this.key.channel();
            if (channel.isOpen()) {
                try { 
                    channel.close();
                } catch (final IOException ignore) {}
            }