//过滤掉字符串中的无效字符
public static String delInvalidChar(String str) {
if (str == null || str.equals("")) {
return "";
}
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
//如果是无效字符,则替换成空字符
if ((ch >= 0x00 && ch <= 0x08)
|| (ch >= 0x0b && ch <= 0x0c)
|| (ch >= 0x0e && ch <= 0x1f)) {
str = str.replace(ch, ' ');
}
}
return str;
}
public static String delInvalidChar(String str) {
if (str == null || str.equals("")) {
return "";
}
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
//如果是无效字符,则替换成空字符
if ((ch >= 0x00 && ch <= 0x08)
|| (ch >= 0x0b && ch <= 0x0c)
|| (ch >= 0x0e && ch <= 0x1f)) {
str = str.replace(ch, ' ');
}
}
return str;
}