Here you can find the source of truncate(String s)
public static String truncate(String s)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w .j ava 2 s . c o m * Truncate the input string to be at most the input length * @param s The string to truncate * @param length The maximum length * @return A truncated string with length 15, or the input string */ public static String truncate(String s, int length) { if (s.length() <= length) return s; return s.substring(0, length); } public static String truncate(String s) { return truncate(s, 15); } }