public class Terminal extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Terminal.CommandOutput |
| Constructor and Description |
|---|
Terminal() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
breakOnError() |
Terminal |
breakOnError(boolean breakOnError)
Will throw
IllegalStateException on error when true |
Terminal |
clearConsole()
Clears the console output
consoleInfo() consoleError() |
String |
consoleError() |
String |
consoleInfo() |
Terminal |
consumerError(Consumer<String>... consumerError) |
Terminal |
consumerErrorStream(Consumer<String>... consumerError) |
Terminal |
consumerInfo(Consumer<String>... consumerError) |
Terminal |
consumerInfoStream(Consumer<String>... consumerInfo) |
static Terminal |
copyOf(Terminal terminal)
Clean copy of terminal with default consumer and clean console log
|
int |
countTerminalMessages() |
File |
dir() |
Terminal |
dir(File dir) |
Terminal |
dir(Path dir) |
Terminal |
dir(String dir) |
Terminal |
execute(String command)
Executes a command with (sh or cmd.exe) ant he help of the
ProcessBuilder
Default working directory: user.dir
timeoutMs(long) if timeout is needed |
Terminal |
execute(String command,
long waitForMs)
Executes a command with (sh or cmd.exe) ant he help of the
ProcessBuilder
Default working directory: user.dir
timeoutMs(long) if timeout is needed |
Process |
process() |
Process |
process(String command)
Executes a command with (sh or cmd.exe) with the help of the
ProcessBuilder |
int |
status() |
long |
timeoutMs() |
Terminal |
timeoutMs(long timeoutMs)
Alternative to
Process.waitFor() as sometimes a process can be to fast or to slow for Process.waitFor() or you need a timeout
Its combined with (breakOnError(boolean))
Default : -1 (deactivated)
Also activates a heartbeat check (timeoutMs / 40) which will also timeout if there is no output is happening |
long |
waitFor() |
Terminal |
waitFor(long waitForMs) |
public static Terminal copyOf(Terminal terminal)
terminal - terminal to copypublic Terminal clearConsole()
consoleInfo() consoleError()@SafeVarargs public final Terminal consumerInfoStream(Consumer<String>... consumerInfo)
consumerInfo - consumer for console info stream@SafeVarargs public final Terminal consumerErrorStream(Consumer<String>... consumerError)
consumerError - consumer for console error stream@SafeVarargs public final Terminal consumerInfo(Consumer<String>... consumerError)
consumerError - consumer for console exit code info@SafeVarargs public final Terminal consumerError(Consumer<String>... consumerError)
consumerError - consumer for console exit code errorspublic long timeoutMs()
timeoutMs(long)public Terminal timeoutMs(long timeoutMs)
Process.waitFor() as sometimes a process can be to fast or to slow for Process.waitFor() or you need a timeout
Its combined with (breakOnError(boolean))
Default : -1 (deactivated)
Also activates a heartbeat check (timeoutMs / 40) which will also timeout if there is no output is happeningtimeoutMs - timeout in millisecondspublic boolean breakOnError()
breakOnError(boolean)public Terminal breakOnError(boolean breakOnError)
IllegalStateException on error when truebreakOnError - set statepublic long waitFor()
execute(String, long)public Terminal waitFor(long waitForMs)
execute(String, long)public Process process()
Process - return null when no command was executedpublic String consoleInfo()
public String consoleError()
public Terminal execute(String command)
ProcessBuilder
Default working directory: user.dir
timeoutMs(long) if timeout is neededcommand - command to executeProcess object for managing the sub processpublic Terminal execute(String command, long waitForMs)
ProcessBuilder
Default working directory: user.dir
timeoutMs(long) if timeout is neededcommand - command to executewaitForMs - overwrites default waitFor(long) for this callProcess object for managing the sub processpublic Process process(String command) throws IOException
ProcessBuildercommand - command to executeProcess object for managing the sub processIOException - if an I/O error occurspublic int status()
Process.waitFor()public int countTerminalMessages()
Copyright © 2022. All rights reserved.