简化 SystemUtils (#5315)
This commit is contained in:
@@ -81,13 +81,9 @@ public final class SystemUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T run(List<String> command, ExceptionalFunction<InputStream, T, ?> convert) throws Exception {
|
public static <T> T run(List<String> command, ExceptionalFunction<InputStream, T, ?> convert) throws Exception {
|
||||||
File nul = OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS
|
|
||||||
? new File("NUL")
|
|
||||||
: new File("/dev/null");
|
|
||||||
|
|
||||||
Process process = new ProcessBuilder(command)
|
Process process = new ProcessBuilder(command)
|
||||||
.redirectInput(nul)
|
.redirectInput(ProcessBuilder.Redirect.DISCARD)
|
||||||
.redirectError(nul)
|
.redirectError(ProcessBuilder.Redirect.DISCARD)
|
||||||
.start();
|
.start();
|
||||||
try {
|
try {
|
||||||
InputStream inputStream = process.getInputStream();
|
InputStream inputStream = process.getInputStream();
|
||||||
|
|||||||
Reference in New Issue
Block a user