Here you can find the source of shortenString(String s, int maxLength)
public static String shortenString(String s, int maxLength)
//package com.java2s; // License: GPL. For details, see LICENSE file. public class Main { /**//from www. j a v a 2 s. c o m * If the string {@code s} is longer than {@code maxLength}, the string is cut and "..." is appended. */ public static String shortenString(String s, int maxLength) { if (s != null && s.length() > maxLength) { return s.substring(0, maxLength - 3) + "..."; } else { return s; } } }