|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.util.SystemUtils
public class SystemUtils
Useful methods for running shell commands, getting the process ID, checking memory usage, etc.
run(java.lang.ProcessBuilder)
)Nested Class Summary | |
---|---|
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 Summary | |
---|---|
SystemUtils()
|
Method Summary | |
---|---|
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 . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SystemUtils()
Method Detail |
---|
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()
public static void main(String[] args) throws Exception
Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |