Here you can find the source of truncateAt(String string, int length)
public static String truncateAt(String string, int length)
//package com.java2s; public class Main { public static String truncateAt(String string, int length) { return string.length() > length ? string.substring(0, length) : string;/*ww w . jav a2 s .c o m*/ } }