fix: callExternalProcess() not displaying stderr

This commit is contained in:
Haowei Wen
2021-08-19 02:11:14 +08:00
parent 3c8d17b564
commit 69ded66c92

View File

@@ -17,9 +17,8 @@
*/ */
package org.jackhuang.hmcl.util.platform; package org.jackhuang.hmcl.util.platform;
import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.lang.ProcessBuilder.Redirect;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@@ -31,12 +30,10 @@ public final class SystemUtils {
} }
public static int callExternalProcess(List<String> command) throws IOException, InterruptedException { public static int callExternalProcess(List<String> command) throws IOException, InterruptedException {
Process process = new ProcessBuilder(command).start(); Process process = new ProcessBuilder(command)
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) { .redirectOutput(Redirect.INHERIT)
for (String line; (line = reader.readLine()) != null;) { .redirectError(Redirect.INHERIT)
System.out.println(line); .start();
}
}
return process.waitFor(); return process.waitFor();
} }
} }