Here you can find the source of shortenString(String str, int length)
public static String shortenString(String str, int length)
//package com.java2s; public class Main { public static String shortenString(String str, int length) { if (str.length() > length) { String newStr = str.substring(0, length); return newStr.concat("..."); }/*from w ww. j a va 2s. c o m*/ return str; } }