Format bytes into a rounded string representation using decimal SI units. These are used by hard drive manufacturers for capacity. Most other storage should use #formatBytes(long). @param bytes Bytes. @return Rounded string representation of the byte size.
(long bytes)
| 128 | * @return Rounded string representation of the byte size. |
| 129 | */ |
| 130 | public static String formatBytesDecimal(long bytes) { |
| 131 | if (bytes == 1L) { // bytes |
| 132 | return String.format("%d byte", bytes); |
| 133 | } else if (bytes < KILO) { // bytes |
| 134 | return String.format("%d bytes", bytes); |
| 135 | } else { |
| 136 | return formatValue(bytes, "B"); |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Format hertz into a string to a rounded string representation. |