code: public static String convertToHumanFriendlyByteSize(long size) {
          if (size < 1024) {
              return size + " B";
          }
          int z = (63 - Long.numberOfLeadingZeros(size)) / 10;
          double d = (double)size / (1L << (z * 10));
          String format = (d % 1.0 == 0) ? "%.0f %sB" : "%.1f %sB";
          return String.format(format, d, " KMGTPE".charAt(z));
      }
docs: Convert byte size into human friendly format.
  
  @param size the number of bytes
  @return a human friendly byte size (includes units)