public class SystemUtils
extends java.lang.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
|
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 java.lang.String |
getStackTraceString(java.lang.Throwable t)
Returns the string value of the stack trace for the given Throwable.
|
static java.lang.String |
getTimestampString()
Returns a String representing the current date and time in the format
"20071022-140522".
|
static java.lang.String |
getTimestampString(java.lang.String fmt)
Returns a String representing the current date and time in the given
format.
|
static void |
main(java.lang.String[] args) |
static void |
run(java.lang.ProcessBuilder builder)
Start the process defined by the ProcessBuilder, and run until complete.
|
static void |
run(java.lang.ProcessBuilder builder,
java.io.Writer output,
java.io.Writer error)
Start the process defined by the ProcessBuilder, and run until complete.
|
static void |
runShellCommand(java.lang.String cmd)
Runs the shell command which is specified, along with its arguments, in the
given
String . |
static void |
runShellCommand(java.lang.String[] cmd)
Runs the shell command which is specified, along with its arguments, in the
given
String array. |
static void |
runShellCommand(java.lang.String[] cmd,
java.io.File dir,
java.lang.StringBuilder outputLines,
java.lang.StringBuilder errorLines)
Runs the shell command which is specified, along with its arguments, in the
given
String array. |
static void |
runShellCommand(java.lang.String[] cmd,
java.lang.StringBuilder outputLines)
Runs the shell command which is specified, along with its arguments, in the
given
String array. |
static void |
runShellCommand(java.lang.String[] cmd,
java.lang.StringBuilder outputLines,
java.lang.StringBuilder errorLines)
Runs the shell command which is specified, along with its arguments, in the
given
String array. |
static void |
runShellCommand(java.lang.String cmd,
java.lang.StringBuilder outputLines)
Runs the shell command which is specified, along with its arguments, in the
given
String . |
static void |
runShellCommand(java.lang.String cmd,
java.lang.StringBuilder outputLines,
java.lang.StringBuilder errorLines)
Runs the shell command which is specified, along with its arguments, in the
given
String . |
public static void run(java.lang.ProcessBuilder builder)
builder
- The ProcessBuilder defining the process to run.public static void run(java.lang.ProcessBuilder builder, java.io.Writer output, java.io.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(java.lang.String[] cmd, java.lang.StringBuilder outputLines, java.lang.StringBuilder errorLines) throws java.io.IOException
String
array. If there is any regular output or error
output, it is appended to the given StringBuilder
s.java.io.IOException
public static void runShellCommand(java.lang.String[] cmd, java.io.File dir, java.lang.StringBuilder outputLines, java.lang.StringBuilder errorLines) throws java.io.IOException
String
array. If there is any regular output or error
output, it is appended to the given StringBuilder
s.java.io.IOException
public static void runShellCommand(java.lang.String cmd, java.lang.StringBuilder outputLines, java.lang.StringBuilder errorLines) throws java.io.IOException
String
. If there is any regular output or error output,
it is appended to the given StringBuilder
s.java.io.IOException
public static void runShellCommand(java.lang.String[] cmd, java.lang.StringBuilder outputLines) throws java.io.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 (!).java.io.IOException
public static void runShellCommand(java.lang.String cmd, java.lang.StringBuilder outputLines) throws java.io.IOException
String
. If there is any regular output, it is appended
to the given StringBuilder
. If there is any error output, it
is swallowed (!).java.io.IOException
public static void runShellCommand(java.lang.String[] cmd) throws java.io.IOException
String
array. If there is any output, it is swallowed (!).java.io.IOException
public static void runShellCommand(java.lang.String cmd) throws java.io.IOException
String
. If there is any output, it is swallowed (!).java.io.IOException
public static int getPID() throws java.io.IOException
java.io.IOException
public static int getPIDNoExceptions()
public static int getMemoryInUse()
public static java.lang.String getStackTraceString(java.lang.Throwable t)
public static java.lang.String getTimestampString(java.lang.String fmt)
public static java.lang.String getTimestampString()
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception