Runtime.Exec and windows batch file
Hi Im trying to run an Exec(Blah.bat) however it seems to be freezing
for some reason if the exec returns errors then the Exec does not freez
however if run the file and all i get is output it just freezes.
How would i handle output from the Batch file diferently ?
proc = rt.exec(cmd);
stderr = proc.getErrorStream();
isr = new InputStreamReader(stderr);
br = new BufferedReader(isr);
iostr = proc.getInputStream();
ist = new InputStreamReader(iostr);
bri = new BufferedReader(ist);
stdoutt = proc.getOutputStream();
ost = new OutputStreamWriter(stdoutt);
bwr = new BufferedWriter(ost);
String line2;
while ( (line = br.readLine()) != null && (line2 = bri.readLine()) !=
null)
{
line2 = null;
while ( (line2 = bri.readLine()) != null)
{
System.out.println("Error:" + line2 + ":Error");
}
System.out.println("VVVVVVV");
myString = line;
System.out.println("Error:" + line + ":Error");
}
//Im asuming that it freezes somewere before this wait for proc
command
System.out.println("waiting for proc");
exitVal = proc.waitFor();
if(exitVal > 0)
{
System.out.println("exitVal: " + exitVal);
}