Here you can find the source of truncateString(String s, int numChars)
public static String truncateString(String s, int numChars)
//package com.java2s; //License from project: BSD License public class Main { public static String truncateString(String s, int numChars) { if (s != null && s.length() > numChars) { s = s.substring(0, numChars); }//from ww w. ja v a 2s. c om return s; } }