出现这种情况,极有可能就是两个字符串的编码不同。解决办法:
直接两个方法拷过去
public static String deleteUTF8Bom(String fileStr) {
byte[] UTF8_BOM_BYTES = new byte[]{(byte) 0xEF, (byte) 0xBB, (byte) 0xBF};
byte[] bytes = fileStr.getBytes();
if (bytes[0] == UTF8_BOM_BYTES[0]
&& bytes[1] == UTF8_BOM_BYTES[1]
&& bytes[2] == UTF8_BOM_BYTES[2]) {
return new String(bytes, 3, bytes.length - 3);
}
return fileStr;
}
public static boolean equlsTwoString(String one,String two){
if(!one.equals(two)){
if(deleteUTF8Bom(one).equals(deleteUTF8Bom(two))){
return true;
}else {
return false;
}
}else {
return true;
}
}