List of utility methods to do Byte Value Format
long | bytesToMegabytes(long bytes) bytes To Megabytes return bytes / MEGABYTE;
|
String | byteToHuman(long bytes, boolean si) byte To Human int unit = si ? 1000 : 1024; if (bytes < unit) { return bytes + " B"; int exp = (int) (Math.log(bytes) / Math.log(unit)); String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i"); return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre); |
String | byteToHumanreadable(long b) byte To Humanreadable return (b / 1048576) + " MB"; |
int | byteToMeg(long bytes) Converts bytes to megabytes. return (int) (bytes / MB); |