Here you can find the source of abbreviate(String s, int length)
public static String abbreviate(String s, int length)
//package com.java2s; public class Main { public static String abbreviate(String s, int length) { if (s == null) return null; if (s.length() <= length) return s; s = s.substring(0, length - 5);//from w w w . j av a2 s .c o m if (s.endsWith(" ")) { s += "..."; } else { s += " ..."; } return s; } }