public static String formetFileSize(long fileSize) {
DecimalFormat df = new DecimalFormat("#.00");
String fileSizeStr = "";
if (fileSize < 1024) {
fileSizeStr = df.format((double) fileSize) + "B";
} else if (fileSize < 1048576) {
fileSizeStr = df.format((double) fileSize / 1024) + "K";
} else if (fileSize < 1073741824) {
fileSizeStr = df.format((double) fileSize / 1048576) + "M";
} else {
fileSizeStr = df.format((double) fileSize / 1073741824) + "G";
}
return fileSizeStr;
}
DecimalFormat df = new DecimalFormat("#.00");
String fileSizeStr = "";
if (fileSize < 1024) {
fileSizeStr = df.format((double) fileSize) + "B";
} else if (fileSize < 1048576) {
fileSizeStr = df.format((double) fileSize / 1024) + "K";
} else if (fileSize < 1073741824) {
fileSizeStr = df.format((double) fileSize / 1048576) + "M";
} else {
fileSizeStr = df.format((double) fileSize / 1073741824) + "G";
}
return fileSizeStr;
}