标签:
若存在特殊字符用此方法,效率高,若不存在就用replace
public static String repStr(String str) {
if(str == null) {
return null;
}
char[] array = str.toCharArray();
for (int i = 0, length = array.length; i < length; i++) {
if(array[i] == ‘+‘) {
array[i] = ‘~‘;
} else if(array[i] == ‘/‘) {
array[i] = ‘_‘;
} else if(array[i] == ‘=‘) {
array[i] = ‘.‘;
}
}
return new String(array);
}
标签:
原文地址:http://www.cnblogs.com/yqlwl66/p/4279957.html