验证中...
Languages: Java
Categories: 编程语言基础
Latest update 2019-06-12 22:34
gistfile1.txt
Raw Copy
public static String displayFileSize(long size) {
//org.apache.commons.io.FileUtils
if (size >= FileUtils.ONE_EB) {
return String.format("%.2f EB", (float) size / FileUtils.ONE_EB);
}
if (size >= FileUtils.ONE_PB) {
return String.format("%.2f PB", (float) size / FileUtils.ONE_PB);
}
if (size >= FileUtils.ONE_TB) {
return String.format("%.2f TB", (float) size / FileUtils.ONE_TB);
}
if (size >= FileUtils.ONE_GB) {
return String.format("%.2f GB", (float) size / FileUtils.ONE_GB);
}
if (size >= FileUtils.ONE_MB) {
return String.format("%.2f MB", (float) size / FileUtils.ONE_MB);
}
if (size >= FileUtils.ONE_KB) {
return String.format("%.2f KB", (float) size / FileUtils.ONE_KB);
}
return String.format("%d bytes", size);
}

Comment list( 0 )

You need to Sign in for post a comment

Help Search

Gitee_you_jiang_zheng_wen Zheng_wen_close