Is there a method in Java to automatically ellipsize a string? Just in Java, not other libraries.
Thanks.
There is not. But here's another crack at a simple method to do this.
String ellipsize(String input, int maxLength) { if (input == null || input.length() < maxLength) { return input; } return input.substring(0, maxLength) + "..."; }