JAVA 監視Windows系統的進程代碼

該代碼列出 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);
}
}
}
ps教程
來源:http://www.huiyi8.com/jiaocheng/
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章