Here you can find the source of ReadableByteCount(long bytes)
public static String ReadableByteCount(long bytes)
//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 }