public synchronized void writeTo(OutputStream os,int minWriteAmount) throws IOException {
  while (!atEof()) {
    int writeAmount=minWriteAmount;
    while (!doneWriting && currBufferSize() < minWriteAmount) {
      try {
        wait();
      }
 catch (      InterruptedException e) {
        throw new IllegalStateException(e);
      }
    }
    writeAmount=currBufferSize();
    if (head + writeAmount > buffer.length) {
      os.write(buffer,head,buffer.length - head);
      os.write(buffer,0,writeAmount - (buffer.length - head));
      head=writeAmount - (buffer.length - head);
    }
 else {
      os.write(buffer,head,writeAmount);
      head+=writeAmount;
    }
  }
}

public synchronized void writeTo ( OutputStream os , int minWriteAmount ) throws IOException { while ( ! atEof ( ) ) { int writeAmount = minWriteAmount ; while ( ! doneWriting && currBufferSize ( ) < minWriteAmount ) { try { wait ( ) ; } catch ( InterruptedException e ) { throw new IllegalStateException ( e ) ; } } writeAmount = currBufferSize ( ) ; if ( head + writeAmount > buffer . length ) { os . write ( buffer , head , buffer . length - head ) ; os . write ( buffer , 0 , writeAmount - ( buffer . length - head ) ) ; head = writeAmount - ( buffer . length - head ) ; } else { os . write ( buffer , head , writeAmount ) ; head += writeAmount ; } } }
writes all the data from os until eof to the output stream
