replaceAll()里面用的是正则表达式

四个“\”代表一个“\”

代码1:

String str = "A\\B\\C";
System.out.println(str);
System.out.println(str.replaceAll("\\\\",""));

输出1:

A\B\C
ABC

代码2:

String str = "AB\n\tC";
System.out.println(str);
System.out.println("替换后:"+str.replaceAll("\n|\t",""));

输出2:

AB
	C
替换后:ABC