Java tutorial
//package com.java2s; import java.text.DecimalFormat; public class Main { public static String getDataSize(long var0) { DecimalFormat var2 = new DecimalFormat("###.00"); return var0 < 1024L ? var0 + "bytes" : (var0 < 1048576L ? var2.format((double) ((float) var0 / 1024.0F)) + "KB" : (var0 < 1073741824L ? var2.format((double) ((float) var0 / 1024.0F / 1024.0F)) + "MB" : (var0 < 0L ? var2.format((double) ((float) var0 / 1024.0F / 1024.0F / 1024.0F)) + "GB" : "error"))); } }