The following example shows how to capture the output from an external process. This process
could be a DOS Batch script process, VB script process or any other process. Please note that
the Batch process's input stream becomes output and output stream becomes input for your java program.
String line; try {
Process proc = Runtime.getRuntime().exec("C:\\ex_proc_out.bat");
BufferedReader procInput = new BufferedReader( new InputStreamReader(proc.getInputStream()));
//Read output from batch process while ((line = procInput.readLine()) != null) {
System.out.println(line);
}