public class ShellCommandExecutor extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
ShellCommandExecutor.OutputParser<T> |
static class |
ShellCommandExecutor.ToStringOutputParser |
Constructor and Description |
---|
ShellCommandExecutor(File executionFolder,
Map<String,String> environment,
long timeoutMillis) |
Modifier and Type | Method and Description |
---|---|
<T> T |
executeCommand(ShellCommandExecutor.OutputParser<T> outputParser,
byte[] input,
String... command)
Executes given shell command, supplies to it provided input, and returns parsed output
|
<T> T |
executeCommand(ShellCommandExecutor.OutputParser<T> outputParser,
String... command)
Executes given shell command and returns parsed output
|
<T> T |
executeCommandReadingError(ShellCommandExecutor.OutputParser<T> errorParser,
String... command)
Executes given shell command and returns parsed error stream
|
public <T> T executeCommand(ShellCommandExecutor.OutputParser<T> outputParser, String... command) throws IOException, InterruptedException, TimeoutException
T
- Type of parsed command outputoutputParser
- Parses that is used to process command outputcommand
- Command to be executedIOException
- If an error was encountered while writing command input or reading outputTimeoutException
- If timeout was reached while waiting for command to finishInterruptedException
- If current thread was interrupted while waiting for command to
finishpublic <T> T executeCommand(ShellCommandExecutor.OutputParser<T> outputParser, byte[] input, String... command) throws IOException, InterruptedException, TimeoutException
T
- Type of parsed command outputoutputParser
- Parses that is used to process command outputinput
- Bytes that are written to command's input streamcommand
- Command to be executedIOException
- If an error was encountered while writing command input or reading outputTimeoutException
- If timeout was reached while waiting for command to finishInterruptedException
- If current thread was interrupted while waiting for command to
finishpublic <T> T executeCommandReadingError(ShellCommandExecutor.OutputParser<T> errorParser, String... command) throws IOException, InterruptedException, TimeoutException
T
- Type of parsed command outputerrorParser
- Parses that is used to process command's error streamcommand
- Command to be executedIOException
- If an error was encountered while writing command input or reading outputTimeoutException
- If timeout was reached while waiting for command to finishInterruptedException
- If current thread was interrupted while waiting for command to
finishCopyright © 2016–2024. All rights reserved.