Java执行电脑cmd命令

直接上代码

// write your code here
// String[] command = new String[]{"ipconfig", "/all"};
String [] command=new String[]{"ping","www.baidu.com"};
Process process = Runtime.getRuntime().exec(command);

InputStream is = process.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(is, Charset.forName("GBK"));
BufferedReader reader = new BufferedReader(inputStreamReader);
for (String line = null; (line = reader.readLine()) != null; ) {
    System.out.println(line);
}
reader.close();

效果


Java执行电脑cmd命令

展开阅读全文

页面更新:2024-04-27

标签:命令   效果   代码   数码   电脑

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top