Here you can find the source of humanBytes(double value)
public static String humanBytes(double value)
//package com.java2s; //License from project: Apache License public class Main { public static String humanBytes(double value) { String suffix = " B"; if (value > 1024) { value /= 1024;/*from ww w.ja v a2 s.co m*/ suffix = " KB"; } if (value > 1024) { value /= 1024; suffix = " MB"; } if (value > 1024) { value /= 1024; suffix = " GB"; } if (value > 1024) { value /= 1024; suffix = " TB"; } return String.valueOf(Math.round(value * 100.0) / 100.0) + suffix; } }