Here you can find the source of truncate(String eval, String suffix, int targetLength)
public static String truncate(String eval, String suffix, int targetLength)
//package com.java2s; //License from project: Apache License public class Main { public static String truncate(String eval, String suffix, int targetLength) { if (eval.length() > targetLength) return eval.substring(0, targetLength - 1) + suffix; else/*from www. j av a 2 s .c om*/ return eval; } }