Here you can find the source of humanizeBytes(long bytes)
public static String humanizeBytes(long bytes)
//package com.java2s; //License from project: Open Source License public class Main { public static String humanizeBytes(long bytes) { int unit = 1000; // 1024 for non-SI units if (bytes < unit) return bytes + " B"; int exp = (int) (Math.log(bytes) / Math.log(unit)); return String.format("%.1f %sB", bytes / Math.pow(unit, exp), "kMGTPE".charAt(exp - 1)); }/* ww w .ja va2 s. co m*/ }