Example #1
0
 public static String readableFileSize(long size) {
   if (size <= 0) return "0";
   final String[] units = new String[] {"B", "KB", "MB", "GB", "TB"};
   int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
   return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups))
       + " "
       + units[digitGroups];
 }
Example #2
0
 private long normalizeMax(long l) {
   int exp = (int) Math.log10((double) l);
   long multiple = (long) Math.pow(10.0, exp);
   int i = (int) (l / multiple);
   l = (i + 1) * multiple;
   return l;
 }