Android Long Format ReadableByteCount(long bytes)

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

Description

Readable Byte Count

Declaration

public static String ReadableByteCount(long bytes) 

Method Source Code

//package com.java2s;

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

Related

  1. formatSpaceSize(long file_size)
  2. formatPercent(long divisor, long dividend)
  3. formatSize(long value)
  4. getTimeFormattedFromMillis(long millis)
  5. formatFileSize(long length)
  6. getDisplayable(long numBytes)
  7. formatByte(long l)
  8. formatFromSize(long size)