Here you can find the source of truncateByCharLength(String string, int maxLength)
public static String truncateByCharLength(String string, int maxLength)
//package com.java2s; //License from project: Open Source License public class Main { public static String truncateByCharLength(String string, int maxLength) { return string.length() > maxLength ? string.substring(0, maxLength) : string; }/*from w ww . j a va 2s . c om*/ }