List of utility methods to do File Size Readable Format
double | getSizeInKbytes(final File path) Gets the size of the path in kbytes. return getSize(path) / ONE_KB_BYTES;
|
double | getSizeInMegabytes(final File path) Gets the size of the path in megabytes. return getSize(path) / (ONE_KB_BYTES * ONE_KB_BYTES);
|
String | formatFileSize(long fileLength) format File Size DecimalFormat df = new DecimalFormat("#.00"); String fileSizeStr = ""; if (fileLength < 1024) fileSizeStr = df.format((double) fileLength) + "B"; else if (fileLength < 1048576) fileSizeStr = df.format((double) fileLength / 1024) + "KB"; else if (fileLength < 1073741824) fileSizeStr = df.format((double) fileLength / 1048576) + "MB"; ... |
String | fileSizeFormat(long length) file Size Format return fileSizeFormat(length, 0);
|
String | fileSizeFormat(long length, int lev) file Size Format if (length > 1024 && lev < 6) { return fileSizeFormat(length / 1024, lev + 1); } else { switch (lev) { case 0: return "" + length; case 1: return length + "K"; ... |
String | FormetFileSize(long fileS) Formet File Size DecimalFormat df = new DecimalFormat("#0.00"); String fileSizeString = ""; if (fileS < 1024) { fileSizeString = df.format((double) fileS) + "B"; } else if (fileS < 1048576) { fileSizeString = df.format((double) fileS / 1024) + "K"; } else if (fileS < 1073741824) { fileSizeString = df.format((double) fileS / 1048576) + "M"; ... |