小编pwa*_*t01的帖子

在Runtime.getRuntime().exec中有两个可执行文件的空格

我有一个命令,我需要在这些行中使用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)

但似乎都没有做任何事情.我有什么问题吗?

java process runtime.exec java-7

12
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×1

java-7 ×1

process ×1

runtime.exec ×1