Java过滤字符串无效字符
来源:互联网 发布:阿里云 安骑士 编辑:程序博客网 时间:2024/05/16 06:46
//过滤掉字符串中的无效字符
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;
}
阅读全文
0 0
- Java过滤字符串无效字符
- 过滤无效输入字符
- XML无效字符过滤
- java如何过滤无效的utf-8字符?
- java过滤字符串中非数字字符
- [C/C++]_[初级]_[替换过滤utf8字符串里无效字符]
- 过滤XML文件中的无效字符
- java 使用正则来过滤字符串中的特殊字符
- java 使用正则来过滤字符串中的特殊字符
- Java 使用正则表达式过滤字符串中的特殊字符
- 过滤无效字符串的方法 ----------T-SQL
- Java 过滤不安全字符
- java过滤特殊字符
- java过滤非法字符
- java 过滤特殊字符
- java 过滤特殊字符
- java 过滤特殊字符
- JAVA过滤特殊字符
- Android学习问题大集合(持续跟新中)
- HDU 6033 简单计数
- 关于 ClassLoader.loadClass() 与 Class.forName() 关系
- 恩格尔伯格诞辰,给机器人装上眼睛和小脑
- Android 利用Matrix实现图片随手指平移、旋转、缩放
- Java过滤字符串无效字符
- 利用HorizontalScrollView实现仿QQ的侧滑菜单
- exercise7
- Appium swip滑动
- [SAM] POJ1509 Glass Beads
- 【react】map 遍历json数据
- AttributeError: addinfourl instance has no __call__ method
- 在Eclipse中使用Maven构建Spring项目
- C++——NOIP2016提高组day1 t3——换教室