code: public static String trim(String s, int maxWidth) {
      if (s.length() <= maxWidth) {
        return (s);
      }
      return (s.substring(0, maxWidth));
    }
docs: Returns s if it's at most maxWidth chars, otherwise chops right side to fit.