Here you can find the source of formatBytesHumanReadable(float number)
public static String formatBytesHumanReadable(float number)
//package com.java2s; //License from project: Open Source License public class Main { public static String formatBytesHumanReadable(float number) { String unit = "bytes"; if (number > 1024) { number /= 1024;//w ww. ja v a 2s . co m unit = "KiB"; } if (number > 1024) { number /= 1024; unit = "MiB"; } number = (float) ((long) (number * 1000)) / 1000; return number + " " + unit; } }