MCPcopy Create free account
hub / github.com/Hello-hao/Tbed / readableFileSize

Method readableFileSize

src/main/java/cn/hellohao/utils/SetFiles.java:69–89  ·  view source on GitHub ↗
(long fileS)

Source from the content-addressed store, hash-verified

67
68 //文件大小单位转换
69 public static String readableFileSize(long fileS) {
70 if(fileS==0){
71 return "0B";
72 }
73 DecimalFormat df = new DecimalFormat("#.00");
74 String fileSizeString = "";
75 if (fileS < 1024) {
76 fileSizeString = df.format((double) fileS) + "B";
77 } else if (fileS < 1048576) {
78 fileSizeString = df.format((double) fileS / 1024) + "KB";
79 } else if (fileS < 1073741824) {
80 fileSizeString = df.format((double) fileS / 1048576) + "MB";
81 } else {
82 if(fileS < 1099511627776L){
83 fileSizeString = df.format((double) fileS / 1073741824) + "GB";
84 }else{
85 fileSizeString = df.format((double) fileS / 1099511627776L) + "TB";
86 }
87 }
88 return fileSizeString;
89 }
90
91 public static String generatePath(String uploadFolder, Chunk chunk) {
92 StringBuilder sb = new StringBuilder();

Callers 3

LoadInfoMethod · 0.95
overviewDataMethod · 0.95
SpaceExpansionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected