replaceAll替换换行符,直接用replaceAll(“\n”, " ")不起作用,正则表达式中\是特殊字符,得先转义
public static void main(String[] args) {
String test = "ONE: this is a\ntest string.";
System.out.println(test);
String test1 = test.replaceAll("\n", " ");
String test2 = test.replaceAll("\r\n", " ");
System.out.println(test1);
System.out.println(test2);
}