Here you can find the source of removeSuffix(String str, String suffix)
public static String removeSuffix(String str, String suffix) throws Exception
//package com.java2s; public class Main { public static String removeSuffix(String str, String suffix) throws Exception { if (null == str) return null; if ("".equals(str.trim())) return ""; if (null == suffix || "".equals(suffix)) return str; if (str.endsWith(suffix)) { return str.substring(0, str.length() - suffix.length()); }/* w w w . ja v a 2 s .c om*/ throw new Exception(str + " ????????" + suffix + "??"); } public static String subString(String str, int length) { if (isBlank(str)) { return ""; } else if (str.length() > length) { return str.substring(0, length); } else { 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; } }