Tag: 字符串以

Java中的特殊字符\ 0 {NUL}

如何在String中替换\ 0(NUL)? String b = “2012yyyy06mm”; // sth what i want String c = “2\0\0\0012yyyy06mm”; String d = c.replaceAll(“\\\\0”, “”); // not work String e = d.replace(“\0”, “”); // er, the same System.out.println(c+”\n”+d+”\n”+e); String bb = “2012yyyy06mm”; System.out.println(b.length() + ” > ” +bb.length()); 上面的代码将在控制台中打印12> 11。 哎呀,发生什么事了? String e = c.replace(“\0”, “”); System.out.println(e); // just print […]