Here you can find the source of subStr(String str, int maxLen)
public static String subStr(String str, int maxLen)
//package com.java2s; public class Main { public static String subStr(String str, int maxLen) { if (str == null) { return null; }/*from w w w.j a v a 2s . c o m*/ if (maxLen < 1) { return str; } if (str.length() > maxLen) { return str.substring(0, maxLen) + "..."; } return str; } }