private void flushPart() throws IOException {
        int size = (_streamPos >= _pos) ? (_bufferSize - _streamPos) : (_pos - _streamPos);

        if (_stream != null) {
            _stream.write(_buffer, _streamPos, size);
        }
        _streamPos += size;
        if (_streamPos == _bufferSize)
            _streamPos = 0;
        if (_pos == _bufferSize) {
            _pos = 0;
        }
        _limitPos = (_streamPos > _pos) ? _streamPos : _bufferSize;
        _processedSize += size;
    }