code: private static void writeFully(WritableByteChannel ch, ByteBuffer bb)
          throws IOException
      {
          if (ch instanceof SelectableChannel) {
              SelectableChannel sc = (SelectableChannel)ch;
              synchronized (sc.blockingLock()) {
                  if (!sc.isBlocking())
                      throw new IllegalBlockingModeException();
                  writeFullyImpl(ch, bb);
              }
          } else {
              writeFullyImpl(ch, bb);
          }
      }
docs: Write all remaining bytes in buffer to the given channel.
  
  @throws  IllegalBlockingException
  If the channel is selectable and configured non-blocking.