0

当我在 IDE 中执行此类时main,一切正常:

Runtime p = Runtime.getRuntime();
String[] commands = new String[3];
commands[0] = "cmd";
commands[1] = "/c";
commands[2] = "\\something\\something\\curl.exe ... ;
Process x = p.exec(commands);

BufferedReader in = new BufferedReader(
new InputStreamReader(x.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}

但是如果我构建 WAR 并从 Web 应用程序执行此方法 - 包含 null 的行(p.exec(commands)- 无法正常工作),我该如何改善这种情况?

4

0 回答 0