Here you can find the source of truncate(String text, int length)
private static String truncate(String text, int length)
//package com.java2s; //License from project: Apache License public class Main { private static String truncate(String text, int length) { return text.length() > length ? text.substring(0, length - 1) + "..." : text; }/* ww w .j av a2 s .c o m*/ }