code: private void flushBuffer() throws IOException
      {
          while (_flush.hasRemaining())
          {
              int len=_channel.write(_flush);
              if (len<0)
                  throw new IOException("EOF");
              if (len==0)
              {
                  // write channel full.  Try letting other threads have a go.
                  Thread.yield();
                  len=_channel.write(_flush);
                  if (len<0)
                      throw new IOException("EOF");
                  if (len==0)
                  {
                      // still full.  need to  block until it is writable.
                      if (_selector==null)
                       {
                              _selector=Selector.open();
                              _channel.register(_selector,SelectionKey.OP_WRITE);
                       }
  
                       _selector.select();
                  }
              }
          }
      }
docs: /* -------------------------------------------------------------------------------