Hi I found many threads regarding how to run a dos batch from a java app and ended up getting it working. However I was stuck on the following: Using that code the process never exits, and the app is stuck.
p = Runtime.getRuntime().exec("ant.bat release",null,new File(".");
p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = reader.readLine();
while (line != null) {
line = reader.readLine();
System.out.println("execTest: " + line);
}
now if I do the reading before p.waitFor(), it works. could someone explain this to me?
working code:
p = Runtime.getRuntime().exec("ant.bat release",null,new File(".");
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = reader.readLine();
while (line != null) {
line = reader.readLine();
System.out.println("execTest: " + line);
}
p.waitFor();