Android Long Readable 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) {
        if (bytes < 1024)
            return bytes + " B";
        int exp = (int) (Math.log(bytes) / Math.log(1024));
        String pre = String.valueOf("KMGTPE".charAt(exp - 1));
        return String.format("%.1f %sB", bytes / Math.pow(1024, exp), pre);
    }//from  ww  w.ja  va  2s .  c o  m
}

Related

  1. humanReadableByteCount(long bytes, boolean size)
  2. sizeConvert(long size)
  3. prettyBytes(long value)
  4. getSizeDesc(long size)
  5. humanReadableByteCount(long bytes, boolean si)