我需要通过TCP连接写入的字符串包含\n
和\r
个字符。这些字符打印为\\n
和\\r
。我该如何解决这个问题?
String myLine = "this is first line\r this is second line\r third line";
outputStream.write(myLine);
结果:
this is first line\\r this is second line\\r third line
但我需要写与myLine
相同的结果(只有1个转义序列charecter)值。
答案 0 :(得分:0)
你试过逃避吗?
"this is first line\\\\r this is second line\\\\r third line"