public class RuntimeUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
RuntimeUtil.Response |
Constructor and Description |
---|
RuntimeUtil() |
Modifier and Type | Method and Description |
---|---|
static RuntimeUtil.Response |
execute(int maxBuffer,
File dir,
String... command)
Executes an external command and provides results of execution.
|
static RuntimeUtil.Response |
execute(int maxBuffer,
String... command)
Executes an external command and provides results of execution at the current location.
|
static RuntimeUtil.Response |
execute(String... command)
Executes an external command and provides results of execution.
|
static RuntimeUtil.Response |
execute(String command)
Convenience method, does the same as
execute(String...) , but will
automatically convert a full command string to tokens for convenience. |
public static RuntimeUtil.Response execute(int maxBuffer, String... command)
command
- array containing the command to call and its arguments.maxBuffer
- max size of buffers out, err
. An external process may produce a
lot of output, be careful setting to a large value. The buffer will not be allocated to this
size at the start, but will grow until it reaches it. The program will continue toi execute, and the buffer
will be 'tailing' the output of the external process.RuntimeUtil.Response
with result of execution.public static RuntimeUtil.Response execute(int maxBuffer, File dir, String... command)
command
- array containing the command to call and its arguments.maxBuffer
- max size of buffers out, err
. An external process may produce a
lot of output, be careful setting to a large value. The buffer will not be allocated to this
this size at the start, but will grow until it reaches it. The program will continue toi execute, and the buffer
will be 'tailing' the output of the external process.dir
- - location of process execution. Pass null
to execute at current location of the calling process.RuntimeUtil.Response
with result of execution.public static RuntimeUtil.Response execute(String... command)
command
- array containing the command to call and its arguments.RuntimeUtil.Response
with result of execution.public static RuntimeUtil.Response execute(String command)
execute(String...)
, but will
automatically convert a full command string to tokens for convenience.
Here is how to call:
System.out.println(execute("ls -ls").out);
command
- - a single string representing a command and its arguments.RuntimeUtil.Response
with result of execution.Copyright © 2020 JavaLite. All rights reserved.