ITPub博客

首页 > 应用开发 > Java > JAVA 监视Windows系统的进程代码

JAVA 监视Windows系统的进程代码

原创 Java 作者:严格纪律 时间:2014-06-12 17:23:51 0 删除 编辑
该代码列出 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);
}
}
}
教程
来源:http://www.huiyi8.com/jiaocheng/

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29691626/viewspace-1181582/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-06-04

  • 博文量
    13
  • 访问量
    26538