byte[] data; int offset = 0; int len = src.remaining();  if (!src.hasArray()) { data = new byte [len]; src.get (data, 0, len); } else { offset = src.arrayOffset() + src.position(); data = src.array(); }  OutputStream output = socket.getOutputStream(); boolean completed = false;  try { begin(); socket.getPlainSocketImpl().setInChannelOperation(true); output.write (data, offset, len); completed = true; } finally { end (completed); socket.getPlainSocketImpl().setInChannelOperation(false); }  if (src.hasArray()) { src.position (src.position() + len); }  return len;
return channel.write(src);
  public int write (ByteBuffer src)    throws IOException  {    if (!isConnected())      throw new NotYetConnectedException();    byte[] data;    int offset = 0;    int len = src.remaining();        if (!src.hasArray())	    {        data = new byte [len];        src.get (data, 0, len);	    }    else	    {        offset = src.arrayOffset() + src.position();        data = src.array();	    }		    OutputStream output = socket.getOutputStream();    boolean completed = false;    try  {        begin();        socket.getPlainSocketImpl().setInChannelOperation(true);        output.write (data, offset, len);        completed = true;      }    finally      {        end (completed);        socket.getPlainSocketImpl().setInChannelOperation(false);      }    if (src.hasArray())	    {	src.position (src.position() + len);	    }    return len;  }