Blankj / Blankj/AndroidUtilCode

FileIOUtils#writeFileFromIS 这个方法计算进度时出现了除0的问题

Aperta
#1,481 0 commenti 0 reazioni 1 assegnatario Rivendicata da @Blankj Vedi su GitHub
bug
Lingua principale
Java
Stelle
33.6k
Fork
10.6k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## 描述 Bug

简洁地描述下 Bug。
com.blankj.utilcode.util.FileIOUtils#writeFileFromIS 这个方法计算进度时出现了除0,导致计算出的进度为infinity.
我是结合Retrofit来进行下载,相关代码附在了下面。但发现此工具类不能正确读出总长度,也不能传入总长度值。

- AndroidUtilCode 的版本:'com.blankj:utilcodex:1.30.5'
- 出现 Bug 的设备型号:全部
- 设备的 Android 版本:全部

## 相关代码

```java
ResponseBody responseBody = response.body();
long total = responseBody.contentLength();
boolean writtenToDisk =FileIOUtils.writeFileFromIS(savePath, responseBody.byteStream(), new FileIOUtils.OnProgressUpdateListener() {
@Override
public void onProgressUpdate(double progress) {
retrofitCallBack.onProgress(total, (long) (total*progress),progress,true);
}
});
```
-->
```
put your code here
```

## 异常堆栈

未报异常,但得出的值为infinity

```
put the stack of crash here
```

## 截图

![image](https://user-images.githubusercontent.com/1248528/114694613-4aecaf00-9d4d-11eb-88af-ed6b9b2059bb.png)

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.