|
@@ -125,12 +125,12 @@ public class FileSizeUtil {
|
|
* @param unit 需要转换的目标单位 B KB MB GB TB PB
|
|
* @param unit 需要转换的目标单位 B KB MB GB TB PB
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static Integer convert(long size, String unit) throws Exception {
|
|
|
|
|
|
+ public static Integer convert(Long size, String unit) throws Exception {
|
|
FileSizeUnitType fileSizeUnitType = FileSizeUnitType.get(unit);
|
|
FileSizeUnitType fileSizeUnitType = FileSizeUnitType.get(unit);
|
|
if(Objects.isNull(fileSizeUnitType)){
|
|
if(Objects.isNull(fileSizeUnitType)){
|
|
throw new Exception("单位错误!");
|
|
throw new Exception("单位错误!");
|
|
}
|
|
}
|
|
- if(size == 0){
|
|
|
|
|
|
+ if(size == null || size == 0){
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
BigDecimal bigDecimal = new BigDecimal(size);
|
|
BigDecimal bigDecimal = new BigDecimal(size);
|