Is there a method in Java to automatically ellipsize a string? Just in Java, not other libraries.
Thanks.
Sure, try this one:
public static String ellipsise (String input, int maxLen) {
if (input == null)
return null;
if ((input.length() < maxLen) || (maxLen < 3))
return input;
return input.substring (0, maxLen - 3) + "...";
}
This has the advantage of fixing the bug where the King's English is not used properly :-)