Java运行linux和windows系统命令
来源:互联网 发布:淘宝手机解锁靠谱吗 编辑:程序博客网 时间:2024/04/27 23:01
在java中运行系统命令的代码:
package executiveUnixCmd;import java.io.BufferedReader;import java.io.InputStream;import java.io.InputStreamReader;public class ExecutiveCmd { public static void main(String[] args){ InputStream in = null; String res = ""; String line = null; try { //Process pro = Runtime.getRuntime().exec("C:\\Windows\\System32\\ping www.baidu.com"); Process pro = Runtime.getRuntime().exec(new String[]{"sh","-c","ls -l|grep ^d"}); pro.waitFor(); in = pro.getInputStream(); BufferedReader read = new BufferedReader(new InputStreamReader(in)); while((line=read.readLine())!=null){ res += line+"\r\n"; } System.out.println("INFO:"+res); } catch (Exception e) { e.printStackTrace(); } } }
1 0
- Java运行linux和windows系统命令
- java运行Windows命令
- java调用Linux/Windows系统命令
- 如何在windows系统上运行linux命令
- Linux和Windows系统操作命令集合
- Java运行系统命令
- Windows系统运行命令大全
- windows cmd :运行Linux 命令
- Java判断运行系统是linux还是windows
- Windows系统:开始--运行--命令大全
- Windows 系统 运行命令 合集
- windows系统常用运行命令集锦
- linux和windows命令
- linux下使用top命令查看系统运行状态和进程运行状态
- java 运行 linux shell 命令
- java 运行 linux shell 命令
- 在windows上运行linux命令
- windows 中 运行 的 linux系统
- python编码规范
- 【软考】下午题答题经验总结
- GCD 和延时调用
- 第五届全国职工职业技能大赛决赛焊工决赛闭幕
- Android 拍照并显示在ImageView中(解决图片压缩失真的问题)
- Java运行linux和windows系统命令
- hihocoder 1151 : 骨牌覆盖问题·二
- 快速入门:十分钟学会Python
- 高质量程序设计指南C++/c语言 第四章
- C/S通信---服务器IO多路复用模型之select的使用
- HDU 3308 LCIS
- c++11特性之std::thread--初识
- 【HDU5527 2015长春赛区A】【贪心 特判模拟】Too Rich 最多硬币数支付 因子思想 贪心打补丁
- 实验二 栈和队列的应用