美文网首页
Okio保存文件

Okio保存文件

作者: middle2021 | 来源:发表于2017-01-04 16:06 被阅读229次
    long current = 0;
    BufferedSink sink = Okio.buffer(Okio.sink(ApkFile));
    Buffer buffer = sink.buffer();
    long total = body.contentLength();
    long len;
    int bufferSize = 200 * 1024; //200kb
    BufferedSource source = body.source();
    while ((len = source.read(buffer, bufferSize)) != -1) {
        current += len;
        int progress = ((int) ((current * 100 / total)));
    }
    source.close();
    sink.close();
    

    相关文章

      网友评论

          本文标题:Okio保存文件

          本文链接:https://www.haomeiwen.com/subject/huoovttx.html