* How to redirect the console output from the batch file execution...
* Redirect the output to a String object or Inputstream object....
* The following is my code,
import java.io.File;
import java.io.PrintStream;
public class ReadConsoleOut {
public static void main(String[] args) throws Exception{
File myfile = null;
PrintStream print = null;
Process proc = null;
String file_path = null;
file_path = new String("E:\\test\\runjar.bat");
myfile = new File(file_path);
print = new PrintStream(myfile);
print.write("java -jar run.jar -file \"E:/test/inputfile.xml\" ".getBytes());
proc = Runtime.getRuntime().exec("cmd /c start " + file_path);
}
}
* In the above code jar file will be executed in an separate command prompt , i want to redirect that console output to
String object
* How it is possible?