我有一个命令,我需要在这些行中使用java运行:
C:\path\that has\spaces\plink -arg1 foo -arg2 bar "path/on/remote/machine/iperf -arg3 hello -arg4 world"
Run Code Online (Sandbox Code Playgroud)
当路径没有空格时,此命令工作正常,但是当我有空格时,我似乎无法使其工作.我尝试过以下操作,运行Java 1.7
String[] a = "C:\path\that has\spaces\plink", "-arg1 foo", "-arg2 bar", "path/on/remote/machine/iperf -arg3 hello -arg4 world"
Runtime.getRuntime().exec(a);
Run Code Online (Sandbox Code Playgroud)
以及
String[] a = "C:\path\that has\spaces\plink", "-arg1 foo", "-arg2 bar", "path/on/remote/machine/iperf", "-arg3 hello", "-arg4 world"
Runtime.getRuntime().exec(a);
Run Code Online (Sandbox Code Playgroud)
但似乎都没有做任何事情.我有什么问题吗?