String longString = "This is a very long string that needs to be shortened."; String shortString = StringUtils.abbreviate(longString, 20); System.out.println(shortString);
String shortString = "This is a short string."; String noChangeString = StringUtils.abbreviate(shortString, 40); System.out.println(noChangeString);
import org.apache.commons.lang.StringUtils;