Code example for ClosedChannelException

0
    /* 
     * Status check, must be open. 
     */ 
    private void checkOpen() throws IOException { 
        if (!isOpen()) {
            throw new ClosedChannelException();
        } 
    } 
 
    /* 
     * Status check, must be open and connected, for read and write. 
     */ 
    private void checkOpenConnected() throws IOException { 
        checkOpen(); 
        if (!isConnected()) { 
            throw new NotYetConnectedException();
        } 
    } 
 
    /* 
     * Buffer check, must not null