There are many a situation where a developer will want to execute an OS level command in another process and read not only the standard out (stdout), and standard error (sterr), but also the exit code returned from the process.
To do so, utilize the ProcessBuilder class along with a helper class (ProcessWrapper) that will provide the ability to set a timeout for the process and read the exit code in a separate thread.
Following is an example and the → Continue reading “Using a ProcessBuilder to Execute an OS Level Command and Properly Read the Exit Code from a Java Process”