code: public static String formatFileSize(long size) {
          if (size < 1024)
              return size + " B";
          else if (size < 1024 * 1024)
              return new DecimalFormat("#.# KB").format((double)size / 1024);
          else if (size < 1024 * 1024 * 1024)
              return new DecimalFormat("#.# MB").format((double)size / 1024 / 1024);
  
          return new DecimalFormat("#.# GB").format((double)size / 1024 / 1024 / 1024);
      }
docs: Takes a string with a byte count and converts it into a "nice" representation of size.
  <p/>
  124 b <br>
  34 KB <br>
  12 MB <br>
  2 GB
  <p/>
  Created on May 281, 2004 by Chuck May
  @param size size to format
  @return <code>String</code> with the formatted size