public void writeTo(OutputStream out) throws IOException {
  ByteString[] cachedFlushBuffers;
  byte[] cachedBuffer;
  int cachedBufferPos;
synchronized (this) {
    cachedFlushBuffers=flushedBuffers.toArray(new ByteString[flushedBuffers.size()]);
    cachedBuffer=buffer;
    cachedBufferPos=bufferPos;
  }
  for (  ByteString byteString : cachedFlushBuffers) {
    byteString.writeTo(out);
  }
  out.write(copyArray(cachedBuffer,cachedBufferPos));
}

public void writeTo ( OutputStream out ) throws IOException { ByteString [ ] cachedFlushBuffers ; byte [ ] cachedBuffer ; int cachedBufferPos ; synchronized ( this ) { cachedFlushBuffers = flushedBuffers . toArray ( new ByteString [ flushedBuffers . size ( ) ] ) ; cachedBuffer = buffer ; cachedBufferPos = bufferPos ; } for ( ByteString byteString : cachedFlushBuffers ) { byteString . writeTo ( out ) ; } out . write ( copyArray ( cachedBuffer , cachedBufferPos ) ) ; }
writes the complete contents of this byte array output stream to the specified output stream argument .
