/** * Truncate the supplied string to be no more than the specified length. This method returns an empty string if the supplied * object is null. * * @param obj the object from which the string is to be obtained using {@link Object#toString()}. * @param maxLength the maximum length of the string being returned * @return the supplied string if no longer than the maximum length, or the supplied string truncated to be no longer than the * maximum length (including the suffix) * @throws IllegalArgumentException if the maximum length is negative */ public static String truncate( Object obj, int maxLength ) { return truncate(obj, maxLength, null); }