public class SystemUtils extends Object
run(java.lang.ProcessBuilder)
)Modifier and Type | Class and Description |
---|---|
static class |
SystemUtils.ProcessException
Runtime exception thrown by execute.
|
static class |
SystemUtils.ProcessOutputStream
Helper class that acts as a output stream to a process
|
Constructor and Description |
---|
SystemUtils() |
Modifier and Type | Method and Description |
---|---|
static int |
getMemoryInUse()
Returns the number of megabytes (MB) of memory in use.
|
static int |
getPID()
Returns the process ID, via an awful hack.
|
static int |
getPIDNoExceptions()
Returns the process ID, via an awful hack, or else -1.
|
static void |
main(String[] args) |
static void |
run(ProcessBuilder builder)
Start the process defined by the ProcessBuilder, and run until complete.
|
static void |
run(ProcessBuilder builder,
Writer output,
Writer error)
Start the process defined by the ProcessBuilder, and run until complete.
|
static void |
runShellCommand(String cmd)
Runs the shell command which is specified, along with its arguments, in the
given
String . |
static void |
runShellCommand(String[] cmd)
Runs the shell command which is specified, along with its arguments, in the
given
String array. |
static void |
runShellCommand(String[] cmd,
StringBuilder outputLines)
Runs the shell command which is specified, along with its arguments, in the
given
String array. |
static void |
runShellCommand(String[] cmd,
StringBuilder outputLines,
StringBuilder errorLines)
Runs the shell command which is specified, along with its arguments, in the
given
String array. |
static void |
runShellCommand(String cmd,
StringBuilder outputLines)
Runs the shell command which is specified, along with its arguments, in the
given
String . |
static void |
runShellCommand(String cmd,
StringBuilder outputLines,
StringBuilder errorLines)
Runs the shell command which is specified, along with its arguments, in the
given
String . |
public static void run(ProcessBuilder builder)
builder
- The ProcessBuilder defining the process to run.public static void run(ProcessBuilder builder, Writer output, Writer error)
builder
- The ProcessBuilder defining the process to run.output
- Where the process output should be written. If null, the
process output will be written to System.out.error
- Where the process error output should be written. If null,
the process error output will written to System.err.public static void runShellCommand(String[] cmd, StringBuilder outputLines, StringBuilder errorLines) throws IOException
String
array. If there is any regular output or error
output, it is appended to the given StringBuilder
s.IOException
public static void runShellCommand(String cmd, StringBuilder outputLines, StringBuilder errorLines) throws IOException
String
. If there is any regular output or error output,
it is appended to the given StringBuilder
s.IOException
public static void runShellCommand(String[] cmd, StringBuilder outputLines) throws IOException
String
array. If there is any regular output, it is
appended to the given StringBuilder
. If there is any error
output, it is swallowed (!).IOException
public static void runShellCommand(String cmd, StringBuilder outputLines) throws IOException
String
. If there is any regular output, it is appended
to the given StringBuilder
. If there is any error output, it
is swallowed (!).IOException
public static void runShellCommand(String[] cmd) throws IOException
String
array. If there is any output, it is swallowed
(!).IOException
public static void runShellCommand(String cmd) throws IOException
String
. If there is any output, it is swallowed (!).IOException
public static int getPID() throws IOException
IOException
public static int getPIDNoExceptions()
public static int getMemoryInUse()