code: public static String cap(String str, int capSize) {
        if (str.length() <= capSize) {
           return str;
        }
        if (capSize <= 3) {
           return str.substring(0, capSize);
        }
        return str.substring(0, capSize - 3) + "...";
     }
docs: Return a string that is no longer than capSize, and pad with "..." if
  returning a substring.
  
  @param str
  The string to cap
  @param capSize
  The maximum cap size
  @return The string capped at capSize.