Process listmgr=Runtime.getRuntime().exec("listmgr.exe");//获得一个Process对象 PrintStream nameList=new PrintStream(new BufferedOutputStream()));//获得所执行程序的标准输入流,用于向程序输入 DataInputStream addResult=new DataInputStream(listmgr.getInputStream()));//获得所执行程序的标准输出流。 这个例子是在THINKING IN JAVA 的第15章里的。
如果我要执行的EXE 需要带参数,那又该如何处理?谢谢!
public Process exec(String[] cmdarray) throws IOException Executes the specified command and arguments in a separate process. The command specified by the tokens in cmdarray is executed as a command in a separate process. This has exactly the same effect as exec(cmdarray, null). Runtime累有好几个exec函数, 其实可以查看the API specification for the Java 2 Platform的Runtime类,里面讲解的很详细。 我遇到这种问题时总是查看the API specification ,80%的问题都能解决 :)
PrintStream nameList=new PrintStream(new BufferedOutputStream()));//获得所执行程序的标准输入流,用于向程序输入
DataInputStream addResult=new DataInputStream(listmgr.getInputStream()));//获得所执行程序的标准输出流。
这个例子是在THINKING IN JAVA 的第15章里的。
throws IOException
Executes the specified command and arguments in a separate process.
The command specified by the tokens in cmdarray is executed as a command in a separate process. This has exactly the same effect as exec(cmdarray, null).
Runtime累有好几个exec函数,
其实可以查看the API specification for the Java 2 Platform的Runtime类,里面讲解的很详细。
我遇到这种问题时总是查看the API specification ,80%的问题都能解决 :)