code: public static String formatFilesize(long filesize, Locale locale) {
  
          String result;
          filesize = Math.abs(filesize);
  
          if (Math.abs(filesize) < 1024) {
              result = Messages.get().getBundle(locale).key(Messages.GUI_FILEUTIL_FILESIZE_BYTES_1, new Long(filesize));
          } else if (Math.abs(filesize) < 1048576) {
              // 1048576 = 1024.0 * 1024.0
              result = Messages.get().getBundle(locale).key(
                  Messages.GUI_FILEUTIL_FILESIZE_KBYTES_1,
                  new Double(filesize / 1024.0));
          } else if (Math.abs(filesize) < 1073741824) {
              // 1024.0^3 =  1073741824
              result = Messages.get().getBundle(locale).key(
                  Messages.GUI_FILEUTIL_FILESIZE_MBYTES_1,
                  new Double(filesize / 1048576.0));
          } else {
              result = Messages.get().getBundle(locale).key(
                  Messages.GUI_FILEUTIL_FILESIZE_GBYTES_1,
                  new Double(filesize / 1073741824.0));
          }
          return result;
      }
docs: Returns the formatted filesize to Bytes, KB, MB or GB depending on the given value.<p>
  
  @param filesize in bytes
  @param locale the locale of the current OpenCms user or the System's default locale if the first choice
  is not at hand.
  
  @return the formatted filesize to Bytes, KB, MB or GB depending on the given value