Here you can find the source of subStr(String str, int len)
public static String subStr(String str, int len)
//package com.java2s; //License from project: Open Source License public class Main { public static String subStr(String str, int len) { if (isEmpty(str)) { return ""; }/*from ww w .j a va 2 s .c o m*/ if (str.length() >= len) { return str.substring(0, len) + ".."; } else { return str; } } public static boolean isEmpty(String src) { if (src == null || src.trim().equals("null") || src.trim().equals("")) return true; return false; } public static boolean equals(String str1, String str2) { if (str1 == null) { return str2 == null; } return str1.equals(str2); } }