public void write(ByteBuffer buf,int length) throws IOException {
  final byte[] buffer=_writeBuffer;
  final int bufferLength=buffer.length;
  StreamImpl source=_source;
  while (length > 0) {
    final int writeLength=_writeLength;
    final int sublen=Math.min(length,bufferLength - writeLength);
    buf.get(buffer,writeLength,sublen);
    if (length == sublen) {
      _writeLength=writeLength + length;
      if (_implicitFlush) {
        flush();
      }
      return;
    }
    if (source == null) {
      return;
    }
    source.write(buffer,0,bufferLength,false);
    _position+=bufferLength;
    _writeLength=0;
    length-=sublen;
  }
}

public void write ( ByteBuffer buf , int length ) throws IOException { final byte [ ] buffer = _writeBuffer ; final int bufferLength = buffer . length ; StreamImpl source = _source ; while ( length > 0 ) { final int writeLength = _writeLength ; final int sublen = Math . min ( length , bufferLength - writeLength ) ; buf . get ( buffer , writeLength , sublen ) ; if ( length == sublen ) { _writeLength = writeLength + length ; if ( _implicitFlush ) { flush ( ) ; } return ; } if ( source == null ) { return ; } source . write ( buffer , 0 , bufferLength , false ) ; _position += bufferLength ; _writeLength = 0 ; length -= sublen ; } }
writes a byte buffer
