Browse Source

增加文件大小单位转换

dsx 2 năm trước cách đây
mục cha
commit
aa22e89044

+ 2 - 2
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/FileSizeUtil.java

@@ -125,12 +125,12 @@ public class FileSizeUtil {
      * @param unit 需要转换的目标单位 B KB MB GB TB PB
      * @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);
         if(Objects.isNull(fileSizeUnitType)){
             throw new Exception("单位错误!");
         }
-        if(size == 0){
+        if(size == null || size == 0){
             return 0;
         }
         BigDecimal bigDecimal = new BigDecimal(size);