在Java中运行wget命令时出现IOException

时间:2018-10-09 16:03:40

标签: java wget

当我运行wget命令时,会抛出一个IOExceptionNo such File or Directory

我保证命令正确无误,并在终端上尝试了它。

这是我的代码。

default int execute(String[] command, StdOutLogger logger) throws IOException, InterruptedException {
    ProcessBuilder builder = new ProcessBuilder()
            .command(command)
            .redirectErrorStream(true)
            .directory(new File(System.getProperty("user.home")));
    Process process = builder.start();
    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
    bufferedReader.lines().forEach(logger::log);
    return process.waitFor();
}

0 个答案:

没有答案