public class SystemInfo extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
LINE_SEPARATOR
The current OS line separator.
|
static String |
PROCESS_ID
The JVM process id.
|
| Constructor and Description |
|---|
SystemInfo() |
| Modifier and Type | Method and Description |
|---|---|
Process |
exec(String command)
Executes a command.
|
Process |
exec(String command,
String[] envp,
File dir)
Executes a command.
|
String |
execOut(String command)
Executes a command and returns the output of it.
|
String |
execOut(String command,
String line)
Executes a command sends the given input line and returns the output of
it.
|
String |
execOut(String command,
String[] envp,
File dir,
boolean destroy)
Executes a command and returns the output of it.
|
String |
execOut(String command,
String[] envp,
File dir,
String line,
boolean destroy)
Executes a command sends the given input line and returns the output of
it.
|
ClassLoadingMXBean |
getClassLoadingMXBean()
Returns the classloading MX bean.
|
CompilationMXBean |
getCompilationMXBean()
Returns the compilation MX bean.
|
MemoryMXBean |
getMemoryMXBean()
Returns the memory MX bean.
|
OperatingSystemMXBean |
getOsMXBean()
Returns the operating system MX bean.
|
String |
getProcessId()
Returns the process id.
|
Map<String,Process> |
getProcessMap() |
Runtime |
getRuntime()
Returns the JVM runtime.
|
RuntimeMXBean |
getRuntimeMXBean()
Returns the runtime MX bean.
|
ThreadMXBean |
getThreadMXBean()
Returns the thread MX bean.
|
String |
readLine(Process process)
Reads a line from the command stream.
|
String |
readLine(String command)
Reads a line from the command stream.
|
String |
readLines(Process process)
Reads all the output lines from the command stream.
|
String |
readLines(String command)
Reads all the output lines from the command stream.
|
String |
run(String command)
Executes a command and returns the output of it / exception if any
|
static Process |
runCommandFromStream(InputStream commandStream,
String runName,
String arguments,
boolean deleteOnExit)
Runs a command from its stream data.
|
void |
writeLine(Process process,
String line)
Writes a line to the command stream.
|
void |
writeLine(String command,
String line)
Writes a line to the command stream.
|
public static final String LINE_SEPARATOR
public static final String PROCESS_ID
public Runtime getRuntime()
public RuntimeMXBean getRuntimeMXBean()
public ThreadMXBean getThreadMXBean()
public MemoryMXBean getMemoryMXBean()
public OperatingSystemMXBean getOsMXBean()
public ClassLoadingMXBean getClassLoadingMXBean()
public CompilationMXBean getCompilationMXBean()
public static Process runCommandFromStream(InputStream commandStream, String runName, String arguments, boolean deleteOnExit)
commandStream - the command streamrunName - the run namearguments - the argumentsdeleteOnExit - if should delete on exit?public String getProcessId()
public void writeLine(String command, String line)
command - the commandline - the line to sendpublic void writeLine(Process process, String line)
process - the processline - the line to sendpublic String readLine(String command) throws IOException
command - the commandIOException - implicitpublic String readLine(Process process) throws IOException
process - the processIOException - implicitpublic String readLines(String command) throws IOException
command - the commandIOException - implicitpublic String readLines(Process process) throws IOException
process - the processIOException - implicitpublic String execOut(String command, String line) throws IOException
command - the commandline - the line to sendIOException - implicitpublic String execOut(String command, String[] envp, File dir, String line, boolean destroy) throws IOException
command - the commandenvp - the environment listdir - the directoryline - the line to senddestroy - should destroy process after done?IOException - implicitpublic String execOut(String command) throws IOException
command - the commandIOException - implicitpublic String run(String command)
command - the commandpublic String execOut(String command, String[] envp, File dir, boolean destroy) throws IOException
command - the commandenvp - the environmentdir - the directorydestroy - destroy after completed?IOException - implicitpublic Process exec(String command) throws IOException
command - the commandIOException - implicitpublic Process exec(String command, String[] envp, File dir) throws IOException
command - the commandenvp - the environmentdir - the directoryIOException - implicitCopyright © 2017. All rights reserved.