JAVA 监视Windows系统的进程代码

时间:2014-06-13 19:25:03   收藏:0   阅读:300

该代码列出 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/

JAVA 监视Windows系统的进程代码,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!