Sha256: 29d255fdac6c978dd7c23a8eb9ff1e0cf0478490bf1e51ad79f72b485db6fed2
Contents?: true
Size: 508 Bytes
Versions: 27
Compression:
Stored size: 508 Bytes
Contents
package s3.website; public class ByteHelper { // Adapted from http://stackoverflow.com/a/3758880/219947 public static String humanReadableByteCount(long bytes) { boolean si = true; 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); } }
Version data entries
27 entries across 27 versions & 2 rubygems