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();
网友评论