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