Here you can find the source of truncateIfTooLong(String string, int maxLength)
public static String truncateIfTooLong(String string, int maxLength)
//package com.java2s; //License from project: Open Source License public class Main { public static String truncateIfTooLong(String string, int maxLength) { if (string.length() > maxLength) { return string.substring(0, maxLength) + "..."; } else {// www .ja v a 2 s .c om return string; } } }