Exemplo n.º 1
0
        public override void WriteTo(IBufferedSink p_sink)
        {
            // 需要另一个代理类来获取写入的长度
            ExForwardingSink forwardingSink = new ExForwardingSink(p_sink, _progressListener, ContentLength());
            // 转一下
            IBufferedSink bufferedSink = OkIO.Buffer(forwardingSink);

            // 写数据
            _body.WriteTo(bufferedSink);
            // 刷新写入
            bufferedSink.Flush();
        }
        public override void WriteTo(IBufferedSink p0)
        {
            try
            {
                IBufferedSink bufferedSink;
                countingSink = new CountingSink(this, p0);
                bufferedSink = OkIO.Buffer(countingSink);

                _body.WriteTo(bufferedSink);

                bufferedSink.Flush();
            }
            catch (Java.IO.IOException ex)
            {
                _listener?.OnError(_tag, ex.ToString());
            }
        }