将\ r写入输出流

时间:2011-08-12 18:25:50

标签: java outputstream

我需要通过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)值。

1 个答案:

答案 0 :(得分:0)

你试过逃避吗?

"this is first line\\\\r this is second line\\\\r third line"