比如说运行记事本
- Runtime.getRuntime().exec("notepad");
如果要取得返回的结果
- Process p = Runtime.getRuntime().exec("ipconfig /all");
- InputStreamReader reader = new InputStreamReader( p.getInputStream() );
- BufferedReader br = new BufferedReader(reader);
- String rs = null;
- while( (rs = br.readLine()) != null){
- System.out.println(rs);
- }
- br.close();
- p.destroy();
本文转自 dogegg250 51CTO博客,原文链接:http://blog.51cto.com/jianshusoft/658103,如需转载请自行联系原作者