2016-06-23 37 views

回答

1

您可以用\\n(打印時顯示爲\n)替換所有出現的\n字符。

String str = "this is the exact sequence of chars \n"; 
System.out.print(str.replace("\n", "\\n"); 
+1

爲什麼'String.valueOf('\ n')',而不是簡單的'「\ n」'? –