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

Version Path
s3_website-2.1.16 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.15 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.14 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.13 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.12 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.11 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.10 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.9 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.8 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.7 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.6 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.5 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.4 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.3 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.2 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.1 src/main/java/s3/website/ByteHelper.java
s3_website-2.1.0 src/main/java/s3/website/ByteHelper.java
s3_website-2.0.1 src/main/java/s3/website/ByteHelper.java
s3_website-2.0.0 src/main/java/s3/website/ByteHelper.java
s3_website_monadic-0.0.38 src/main/java/s3/website/ByteHelper.java