List of utility methods to do Memory Format
String | formatMemory(Integer memory) format Memory return String.format("%-9s", String.format("%dM", memory)); |
String | formatMemory(long mem) format Memory long kb = mem / 1024; long mb = kb / 1024; if (mb > 0) return mb + " MB"; else if (kb > 0) return kb + " KB"; else return mem + " B"; ... |
String | formatMemorySize(long arg) Format a memory size with g/m/k quantifiers into its number representation. if (arg >= 1024 * 1024 * 1024) return String.format("%d GB", arg / (1024 * 1024 * 1024)); else if (arg >= 1024 * 1024) return String.format("%d MB", arg / (1024 * 1024)); else if (arg >= 1024) return String.format("%d KB", arg / (1024)); else return String.format("%d", arg); ... |