//字符串如通天塔001,,10002,Test990
public static String addOne4Str(String str){
if(str != null){
int fIndex = -1;
for(int i = 0; i < str.length(); i++){
char c = str.charAt(i);
if (c >= '0' && c <= '9'){
fIndex = i;
break;
}
}
if(fIndex == -1){
return str;
}
int num = Integer.parseInt(str.substring(fIndex, str.length())) + 1;
String zeroStr = addZero4Left(str.substring(fIndex, str.length()), String.valueOf(num));
String preStr = str.substring(0, fIndex);
String wholeStr = preStr + zeroStr + num;
return wholeStr;
}
return str;
}
public static String addZero4Left(String sourceStr, String numberStr){
StringBuffer sb = new StringBuffer();
int len = sourceStr.length() - numStr.length();
for(int i = 0; i < len; i++){
sb.append("0");
}
return sb.toString();
}