public long ReadAll(Sink sink) { if (sink == null) { throw new ArgumentException("sink == null"); } long totalBytesWritten = 0; while (_source.Read(_easyBuffer, Segment.SIZE) != -1) { long emitByteCount = _easyBuffer.CompleteSegmentByteCount(); if (emitByteCount > 0) { totalBytesWritten += emitByteCount; sink.Write(_easyBuffer, emitByteCount); } } if (_easyBuffer.Size > 0) { totalBytesWritten += _easyBuffer.Size; sink.Write(_easyBuffer, _easyBuffer.Size); } return(totalBytesWritten); }
public BufferedSink EmitCompleteSegments() { if (_closed) { throw new IllegalStateException("closed"); } long byteCount = _easyBuffer.CompleteSegmentByteCount(); if (byteCount > 0) { _sink.Write(_easyBuffer, byteCount); } return(this); }