问题: - 如果可执行命令包含任何空格,则System.exec在第一个空格后省略字符串内容。如果包含使用java的空格,则无法执行命令
例如: - 如果命令= “/选择/ GUIInstaller /安装/ ABC DEF gh.bin” 那么Java正在执行命令,一直到/选择/ GUIInstaller /安装/ ABC只和产生的错误像产生java.io.IOException:“/选择/ GUIInstaller /安装/ ABC”:错误= 2,没有这样的文件或目录
protected void launch(final String command)
{
try
{
if(command.contains("null"))
{
logger.error("Installer is not located in the specified folder: "+command);
System.exit(0);
}
runTime.exec(command);
}
catch (IOException ioException) {
logger.error(ioException.getMessage(), ioException);
}
}
是我做的任何错误,请帮我解决这个问题。
环境: - Java7 update9 + RHEL6
尝试'“/选择/ GUIInstaller /安装/ ABC \\ DEF \\ gh.bin”'逃脱的空间 – Tom