lsyf8 发表于 2018-6-23 10:08:10

JAVA 监视Windows系统的进程代码

  该代码列出 Windows 下当前运行的所有进程
  import java.io.*;

  public>  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/
页: [1]
查看完整版本: JAVA 监视Windows系统的进程代码