Okio保存文件

2017-01-04  本文已影响229人  middle2021
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();
上一篇下一篇

猜你喜欢

热点阅读