Code example for ClosedChannelException

0
  } 
 
  public int read (ByteBuffer dst) throws IOException
  { 
    if (!isOpen()) 
      throw new ClosedChannelException();
 
    byte[] buffer = new byte [dst.remaining()];
    int readBytes = in.read (buffer);
 
    if (readBytes > 0)
      dst.put (buffer, 0, readBytes);
 
    return readBytes;
  } 
}