- public static String readableFileSize(long size) {
- if (size <= 0) {
- return "0";
- }
- final String[] units = new String[]{"B", "kB", "MB", "GB", "TB", "PB","EB","ZB"};
- int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
- return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
- }
- public static void main(String[] args) {
- String str= "212132342412";
- String str=MyCommonTool.readableFileSize(Long.parseLong(str)+'l');
- System.out.println("str="+str);
-
- }
相关文章:
-
2022-12-23
-
2022-12-23
-
2022-12-23
-
2022-02-10
-
2022-02-01
-
2022-12-23
-
2022-12-23
-
2022-12-23
猜你喜欢
-
2022-01-22
-
2022-12-23
-
2021-11-17
-
2021-12-24
-
2022-12-23
-
2022-02-17
-
2021-11-17
相关资源
-
下载
2023-03-22
-
下载
2021-06-06
-
下载
2023-03-06