public class ExecUtils extends java.lang.Object
|Modifier||Constructor and Description|
Don't allow instantiation, do allow overrides.
|Modifier and Type||Method and Description|
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.
Windows only directory listing:
outputLinesList = execAndWait( "dir" , true );
Directory listing for MacOSX and similar Unixen:
outputLinesList = execAndWait( "ls -la" , true );
Open Acrobat file in Acrobat reader, if installed (Windows and MacOSX):
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:
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.