Here you can find the source of getSizeAll(final long bytes)
public static String getSizeAll(final long bytes)
//package com.java2s; //License from project: Open Source License import java.text.NumberFormat; import java.util.Locale; public class Main { public static String getSizeAll(final long bytes) { return humanReadableByteCount(bytes, true) + " " + humanReadableByteCount(bytes, false) + " " + formatNumber(bytes) + " B"; }//from ww w. j ava 2 s . c o m public static String humanReadableByteCount(final long bytes) { return humanReadableByteCount(bytes, true); } private static String humanReadableByteCount(final long bytes, final boolean si) { final int unit = si ? 1000 : 1024; if (bytes < unit) { return bytes + " B"; } final int exp = (int) (Math.log(bytes) / Math.log(unit)); final String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i"); return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre); } public static String formatNumber(final long val) { return NumberFormat.getNumberInstance(Locale.US).format(val); } }