public class ExecUtils
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
ExecUtils()
Don't allow instantiation, do allow overrides.
|
Modifier and Type | Method and Description |
---|---|
static java.util.List[] |
execAndWait(java.lang.String command,
boolean doWait)
Execute file/command and wait for command to complete.
|
public static java.util.List[] execAndWait(java.lang.String command, boolean doWait)
command
- The command or file name to execute.doWait
- True to wait for the command to return.Examples:
Windows only directory listing:
List outputLinesList = execAndWait( "dir" , true );
Directory listing for MacOSX and similar Unixen:
List outputLinesList = execAndWait( "ls -la" , true );
Open Acrobat file in Acrobat reader, if installed (Windows and MacOSX):
List outputLinesList = execAndWait( "mydoc.pdf" , false );
Note: On some Unixen and possibly MacOSX, you may need to add a path specifier to get the file "executed." E.g., if the document is in the current directory:
List outputLinesList = execAndWait( "./mydoc.pdf" , false );
When running a file that causes the associated application to start, and doWait is true, execAndWait may not return until that associated application is closed. You should invoke execAndWait on a separate thread if you want the execute the command and allow your program to continue executing concurrently as well.