Code example for NonWritableChannelException

0
 
    if (!isOpen ())
      throw new ClosedChannelException ();
     
    if ((mode & WRITE) == 0)
       throw new NonWritableChannelException ();
 
    int result;
    long oldPosition;
 
    oldPosition = implPosition ();
    seek (position);
    result = write(src);
    seek (oldPosition);
     
    return result;
  } 
 
  public void write (int b) throws IOException
  { 
    ch.write(b);