当我运行wget命令时,会抛出一个IOException
。No 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();
}