public static String abbreviate(String str, int maxWidth) {
        if (null == str) {
            return null;
        }

        if (str.length() <= maxWidth) {
            return str;
        }
        
        return str.substring(0, maxWidth) + "...";
    }
Abbreviates a string to a specified length and then adds an ellipsis
if the input is greater than the maxWidth. Example input:
<pre>
     user1@jivesoftware.com/home
</pre>
and a maximum length of 20 characters, the abbreviate method will return:
<pre>
     user1@jivesoftware.c...
</pre>
@param str the String to abbreviate.
@param maxWidth the maximum size of the string, minus the ellipsis.
@return the abbreviated String, or {@code null} if the string was {@code null}.
xmppserver/src/main/java/org/jivesoftware/util/StringUtils.java