Here you can find the source of getFilesizeString(long size)
public static String getFilesizeString(long size)
//package com.java2s; import java.text.DecimalFormat; public class Main { public static String getFilesizeString(long size) { String tail = ""; if (1024 > size) { tail = "byte"; } else if (1048576 > size) { size = size / 1024;/*from w ww . j a va2 s . c o m*/ tail = "Kb"; } else if (1073741824 > size) { size = size / 1024; tail = "Mb"; } else if (1099511627776.0 > size) { size = (long) (size / 1073741824.0); tail = "Gb"; } return new DecimalFormat("#,###.00").format(size) + tail; } }