我想获得OutputStream的的Process通过启动exec()到控制台。如何才能做到这一点?
这是一些不完整的代码:
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.Reader;
public class RuntimeTests
{
public static void main(String[] args)
{
File path = new File("C:\\Dir\\Dir2");
String command = "cmd /c dir";
Reader rdr = null;
PrintStream prtStrm = System.out;
try
{
Runtime terminal = Runtime.getRuntime();
OutputStream rtm = terminal.exec(command, null, path).getOutputStream();
prtStrm = new PrintStream(rtm);
prtStrm.println();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
慕后森
侃侃尔雅
慕田峪9158850
相关分类