NEED HELP:reading output from ms-dos program (with exec)

I'm trying to execute an ms-dos program using exec,

and reading it's output.

the program is running ,but, I can't see it's output.

I've tried many variations of this code:

Process p = Runtime.getRuntime().exec("file_name");

try { p.waitFor();}

catch(Exception e) {}

BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));

String line;

while((line = input.readLine()) != null )

{

please help mewith this - thanks, froy

System.out.println(line);

}

System.out.println(p.exitValue());

[621 byte] By [froy007] at [2007-9-26 6:35:03]
# 1
The problem with the code is always the same:the line - while((line = input.readLine()) != null )always gives a null pointer exception.
froy007 at 2007-7-1 15:48:12 > top of Java-index,Desktop,Runtime Environment...
# 2
>try { p.waitFor();}This doesn't return until the exec process has finished running. So there is no stream for it to get anything from.
jschell at 2007-7-1 15:48:12 > top of Java-index,Desktop,Runtime Environment...