文章目录
清除空白字符
public static String replaceAllSpace(String text) {
try {
if (text == null) {
return text;
}
//word(mac机)中的特殊符号‘不间断空格’
byte[] bytes = {(byte) 0xC2, (byte) 0xA0};
String UTFSpace = new String(bytes, "utf-8");
text = text.replaceAll(UTFSpace, "");
//全角空格
byte[] bytes2 = {(byte) 0xE3, (byte) 0x80, (byte) 0x80};
UTFSpace = new String(bytes2, "utf-8");
text = text.replaceAll(UTFSpace, "");
text = text.replaceAll("\\s", "");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return text;
}