How to capture the output of another program into a File/String

I needed to capture the output of a dos program in an String/file I tried doing Runtime.getRuntime.exec("ipconfig /all >tmp.txt");but still I am unable to capture the output frm the program which I would like to capture in a file or String.Can anyone help
[279 byte] By [ebistro] at [2007-9-26 4:11:38]
# 1

When you use the Runtime.exec() method, it returns a Process object, that process object has access to the streams; stdout, stdin, and stderr of the application you just executed. what you'll want to monitor is the stdout or stderr streams using the

p.getInputStream() or p.getErrorStream(), where p = the process object returned via the Runtime.exe() method.

klhanich at 2007-6-29 13:16:46 > top of Java-index,Archived Forums,Java Programming...
# 2
If you are running from the command line, just do this:java YourProgram > outputFile.txtThis will put the output from "YourProgram" into a file called "outputFile.txt"
cwhalen at 2007-6-29 13:16:47 > top of Java-index,Archived Forums,Java Programming...