Here you can find the source of truncate(String value, int length)
public static String truncate(String value, int length)
//package com.java2s; public class Main { public static String truncate(String value, int length) { if (value != null && value.length() > length) { value = value.substring(0, length); value += "..."; }// w w w . ja v a 2 s . com return value; } }