当前位置: 技术问答>java相关
在java程序中如何调用dos命令?
来源: 互联网 发布时间:2015-05-17
本文导语: 在java程序中如何调用dos命令? 谢谢! | Process pro = Runtime.getRuntime.exec("cmd") InputStream is = pro.getInputStream(); InputStream isES = pro.getErrorStream(); OutputStream os = pro.getOutputStream(); String sCmd="yourcom...
在java程序中如何调用dos命令?
谢谢!
谢谢!
|
Process pro = Runtime.getRuntime.exec("cmd")
InputStream is = pro.getInputStream();
InputStream isES = pro.getErrorStream();
OutputStream os = pro.getOutputStream();
String sCmd="yourcommand";//such as dir
os.write( sCmd.getBytes() );
//然后你从is和isES中可以得到数据
//用此方法可以实现windows上的telnet
InputStream is = pro.getInputStream();
InputStream isES = pro.getErrorStream();
OutputStream os = pro.getOutputStream();
String sCmd="yourcommand";//such as dir
os.write( sCmd.getBytes() );
//然后你从is和isES中可以得到数据
//用此方法可以实现windows上的telnet
|
Runtime.getRuntime.exec("dir")