简体   繁体   English

使用转义序列创建Java字符串

[英]Creating Java String with Escape Sequence

I am trying to create a String which has the below value, but I am getting a syntax error. 我正在尝试创建一个具有以下值的字符串,但出现语法错误。 can anyone please help on this. 有人可以帮忙吗?

tr -d '\15\32' < shell.sh > com.sh

I need the final output in a String something like the above. 我需要一个类似上述的String中的最终输出。 This is what I've tried: 这是我尝试过的:

String s = "tr -d '\15\32' < shell.sh > com.sh";

But I am getting an error for the above code. 但是上面的代码出现错误。

A \\ in a string literal starts an escape sequence . 字符串文字中的\\开始一个转义序列

Double the \\ in a string literal : \\双击为字符串文字:

String s = "tr -d '\\15\\32' < shell.sh > com.sh";

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

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