简体   繁体   English

将 \r 写入输出流

[英]write \r to outputstream

The string I need to write over TCP connection has \n and \r characters.我需要在 TCP 连接上写入的字符串有\n\r字符。 These characters are printing as \\n and \\r .这些字符打印为\\n\\r How can I solve this?我该如何解决这个问题?

String myLine = "this is first line\r this is second line\r third line";
outputStream.write(myLine);

Result:结果:

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

But I need to write result same as myLine (with only 1 escape sequence charecter) value.但我需要编写与myLine相同的结果(只有 1 个转义序列字符)值。

Have you tried escaping it?你试过escaping吗?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM