Abbreviate a string using ellipses
Question:
Write a java program that abbreviates a string using ellipses.
Solution:
Here is a java example that abbreviates a string with ellipses:
Source: (Example.java)
import org.apache.commons.lang.StringUtils;
public class Example {
public static void main(String[] args) {
String str1 = "supercalifragilisticexpialidocious";
String str2 = StringUtils.abbreviate(str1, 10);
System.out.println(str2);
}
}
Output:
$ java Example
superca...
References:
https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#abbreviate-java.lang.String-int-
Questions answered by this page:
How do I abbreviate a string with ellipses using java