MCPcopy Create free account
hub / github.com/0linlin0/CyberBox / exeCommand

Method exeCommand

Skay_Exp/src/tools/CommandUtils.java:22–34  ·  view source on GitHub ↗

执行指定命令 @param command 命令 @return 命令执行完成返回结果 @throws IOException 失败时抛出异常,由调用者捕获处理

(String command)

Source from the content-addressed store, hash-verified

20 * @throws IOException 失败时抛出异常,由调用者捕获处理
21 */
22 public static String exeCommand(String command) throws IOException {
23 try (
24 ByteArrayOutputStream out = new ByteArrayOutputStream();
25 ) {
26 int exitCode = exeCommand(command, out);
27 if (exitCode == 0) {
28 System.out.println("命令运行成功!");
29 } else {
30 System.out.println("命令运行失败!");
31 }
32 return out.toString(DEFAULT_CHARSET);
33 }
34 }
35
36 /**
37 * 执行指定命令,输出结果到指定输出流中

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected