Here you can find the source of subString(String str, int length)
public static String subString(String str, int length)
//package com.java2s; public class Main { public static String subString(String str, int length) { if (isBlank(str)) { return ""; } else if (str.length() > length) { return str.substring(0, length); } else {/*w ww .j a va 2 s . com*/ return str; } } public static boolean isBlank(String str) { if (null == str) return true; if ("".equals(str.trim())) return true; return false; } public static boolean isBlank(Long str) { if (null == str) return true; return false; } }