code: public static String truncate(String string, int maxLength) {
          if (string.length() > maxLength) {
              return string.substring(0, maxLength);
          }
          return string;
      }
docs: Truncate the String to the max length.
  
  @param string String to truncate
  @param maxLength max length
  @return truncated String