Java Long Number Readable Format humanReadableByteCount(long bytes)

Here you can find the source of humanReadableByteCount(long bytes)

Description

human Readable Byte Count

License

Open Source License

Declaration

static String humanReadableByteCount(long bytes) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    static String humanReadableByteCount(long bytes) {
        int unit = 1024;
        if (bytes < unit)
            return bytes + "B";
        int exp = (int) (Math.log(bytes) / Math.log(unit));
        char pre = "KMGTPE".charAt(exp - 1);
        return String.format("%.1f%s", bytes / Math.pow(unit, exp), pre);
    }/*from   w  ww.j  a v  a 2s. com*/
}

Related

  1. humanreadable(long bytes, boolean si)
  2. humanReadable(long memory)
  3. humanReadable(long number)
  4. humanReadableByteCount(final long bytes)
  5. humanReadableByteCount(final long bytes, final boolean si)
  6. humanReadableByteCount(Long bytes, boolean decimal)
  7. humanReadableByteCount(long bytes, boolean si)
  8. humanReadableByteCount(long bytes, boolean si)
  9. humanReadableByteCount(long bytes, boolean si)