public synchronized int write(InputStream in) throws IOException {
  int readCount=0;
  int inBufferPos=count - filledBufferSum;
  int n=in.read(currentBuffer,inBufferPos,currentBuffer.length - inBufferPos);
  while (n != -1) {
    readCount+=n;
    inBufferPos+=n;
    count+=n;
    if (inBufferPos == currentBuffer.length) {
      needNewBuffer(currentBuffer.length);
      inBufferPos=0;
    }
    n=in.read(currentBuffer,inBufferPos,currentBuffer.length - inBufferPos);
  }
  return readCount;
}

public synchronized int write ( InputStream in ) throws IOException { int readCount = 0 ; int inBufferPos = count - filledBufferSum ; int n = in . read ( currentBuffer , inBufferPos , currentBuffer . length - inBufferPos ) ; while ( n != - 1 ) { readCount += n ; inBufferPos += n ; count += n ; if ( inBufferPos == currentBuffer . length ) { needNewBuffer ( currentBuffer . length ) ; inBufferPos = 0 ; } n = in . read ( currentBuffer , inBufferPos , currentBuffer . length - inBufferPos ) ; } return readCount ; }
writes the entire contents of the specified input stream to this byte stream . bytes from the input stream are read directly into the internal buffers of this streams .
