Here you can find the source of formatSpaceUsage(long size)
static String formatSpaceUsage(long size)
//package com.java2s; //License from project: Apache License public class Main { static String formatSpaceUsage(long size) { if (size < 1e4) return size + "B"; else if (size < 1e7) return "" + Math.round(1D * size / 1024D) + "KB"; else if (size < 1e10) return "" + Math.round(1D * size / 1e6) + "MB"; else/*from w w w. jav a2s. c o m*/ return "" + Math.round(1D * size / 1e9) + "GB"; } }