[英]Is there a method to quote curly braces in a Java String?
I must execute this Java String " find ./tmp -name .SYNC -exec rm -rf {} \\;"
我必须执行这个 Java 字符串" find ./tmp -name .SYNC -exec rm -rf {} \\;"
with getRuntime().exec(command)
.使用getRuntime().exec(command)
。 But it doesn't work!但它不起作用!
I think maybe the problem are the curly braces, because they are highlighted in yellow.我想问题可能出在花括号上,因为它们以黄色突出显示。
I've already tried with \\{} , \\{\\}\\ , '{}' , "'{}'"
, without success.我已经尝试过\\{} , \\{\\}\\ , '{}' , "'{}'"
,但没有成功。
You can check my code below.您可以在下面查看我的代码。
String[] command={"find","./tmp","-name",".SYNC","-exec","rm","-rf","{}","\;" };
String res = Shell.executeCommand(command);
public static String executeCommand(String[] command){
...
p=Runtime.getRuntime().exec(command);
..
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.