开发者

how to calculate upload/download data size in android?

开发者 https://www.devze.com 2023-03-16 09:56 出处:网络
In android, how can I calculate the size of a data开发者_Go百科 which I download or upload from internet?this solution should solve your issue. If not you need to provide some source you are usingFor

In android, how can I calculate the size of a data开发者_Go百科 which I download or upload from internet?


this solution should solve your issue. If not you need to provide some source you are using


For uploading you might know the filesize. for example:

FileInputStream fileInputStream = new FileInputStream(sourceFile); 
int uploadSizeBytes = fileInputStream.available();

For download you may calculate it from loop while reading.

such as:

while(stream.read() != -1){
   bytesRead++ ;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消