重构版功能实现

This commit is contained in:
tiansh
2021-10-22 19:08:08 +08:00
parent 57a2c77bf1
commit 1941a3a7aa
87 changed files with 3644 additions and 2875 deletions
+19 -1
View File
@@ -3,6 +3,7 @@ package cn.hellohao.utils;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.text.DecimalFormat;
public class SetFiles {
// 转换文件方法
@@ -54,7 +55,24 @@ public class SetFiles {
return file;
}
//文件大小单位转换
public static String readableFileSize(long fileS) {
if(fileS==0){
return "0B";
}
DecimalFormat df = new DecimalFormat("#.00");
String fileSizeString = "";
if (fileS < 1024) {
fileSizeString = df.format((double) fileS) + "B";
} else if (fileS < 1048576) {
fileSizeString = df.format((double) fileS / 1024) + "K";
} else if (fileS < 1073741824) {
fileSizeString = df.format((double) fileS / 1048576) + "M";
} else {
fileSizeString = df.format((double) fileS / 1073741824) + "G";
}
return fileSizeString;
}