Chinaunix首页 | 论坛 | 博客
  • 博客访问: 17962
  • 博文数量: 14
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 145
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-04 16:01
文章分类
文章存档

2014年(14)

我的朋友

分类: Java

2014-06-12 17:25:26

该代码列出 Windows 下当前运行的所有进程
import java.io.*;
public class ListProcess {
public static void main(String[] args) throws IOException
{
Runtime runtime = Runtime.getRuntime();
String cmds[] = {"cmd", "/c", "tasklist"};
Process proc = runtime.exec(cmds);
InputStream inputstream = proc.getInputStream();
InputStreamReader inputstreamreader = new InputStreamReader(inputstream);
BufferedReader bufferedreader = new BufferedReader(inputstreamreader);
String line;
while ((line = bufferedreader.readLine()) != null)
{
   System.out.println(line);
}
}
}

来源:
阅读(674) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~