StringUtils: abbreviate(String str, int len)
/*
1) Abbreviate Once upon a time >>>Once upon... * */
import org.apache.commons.lang.StringUtils;
public class StringUtilsTrial {
public static void main(String[] args) {
// String can be max 12 chars including the ...
System.out.println("1) Abbreviate Once upon a time >>>"
+ StringUtils.abbreviate("Once upon a time ", 12));
}
}
Apache-Common-Lang.zip( 248 k)Related examples in the same category