(long fileS)
| 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(); |
no outgoing calls
no test coverage detected