public class ShellUtils extends Object
| 构造器和说明 |
|---|
ShellUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static List<String> |
executeCmd(String pathOrCommand)
Windows版本执行管道命令
|
static List<String> |
executeShell(String pathOrCommand)
Linux版本执行管道命令
|
static List<String> |
executeShell(String[] pathOrCommand) |
public static List<String> executeShell(String[] pathOrCommand) throws InterruptedException, IOException
pathOrCommand - 管道类型的命令,比如ps -aux|grep fox
windows平台使用 Runtime.getRuntime().exec(new String[]{"cmd", "/k", "cmd str"});
linux平台使用 Runtime.getRuntime().exec(new String[]{"sh", "-c", "cmd str"});InterruptedExceptionIOExceptionpublic static List<String> executeShell(String pathOrCommand) throws InterruptedException, IOException
pathOrCommand - 命令行InterruptedException - 异常IOException - 异常public static List<String> executeCmd(String pathOrCommand) throws InterruptedException, IOException
pathOrCommand - 命令行InterruptedException - 异常IOException - 异常Copyright © 2024. All rights reserved.