Here you can find the source of getFileSize(String fileSize)
public static String getFileSize(String fileSize)
//package com.java2s; //License from project: Apache License import java.text.DecimalFormat; public class Main { public static String getFileSize(String fileSize) { String temp = ""; DecimalFormat df = new DecimalFormat("0.00"); double dbFileSize = Double.parseDouble(fileSize); if (dbFileSize >= 1024.0D) { if (dbFileSize >= 1048576.0D) { if (dbFileSize >= 1.073741824E9D) { temp = df.format(dbFileSize / 1024.0D / 1024.0D / 1024.0D) + " GB"; } else { temp = df.format(dbFileSize / 1024.0D / 1024.0D) + " MB"; }// w w w . j a v a 2 s. co m } else { temp = df.format(dbFileSize / 1024.0D) + " KB"; } } else { temp = df.format(dbFileSize / 1024.0D) + " KB"; } return temp; } }