标签:art style bst 字符串 stat print ref oid system
//扩展2个String方法
/*
* 删除开头字符串
*/
public static String trimstart(String inStr, String prefix) {
if (inStr.startsWith(prefix)) {
return (inStr.substring(prefix.length()));
}
return inStr;
}
/*
* 删除末尾字符串
*/
public static String trimend(String inStr, String suffix) {
if (inStr.endsWith(suffix)) {
return (inStr.substring(0,inStr.length()-suffix.length()));
}
return inStr;
}
public static void main(String[] args) {
String testStr1 = ",1,2,3";
System.out.println("trimstart的结果:"+trimstart(testStr1,","));
String testStr2 = "1,2,3,";
System.out.println("trimend的结果:"+trimend(testStr2,","));
}
标签:art style bst 字符串 stat print ref oid system
原文地址:https://www.cnblogs.com/liw66/p/10231899.html