package com.ffshi.util;
import java.io.IOException;
import java.util.Scanner;
public class JavaWindowsCommandUtil {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
// startTask("E:\\Fetion\\Fetion.exe");
killTask("javaw");
}
/**
* 杀死一个进程
*
* @param task
*/
public static void killTask(String task) {
try {
Process process = Runtime.getRuntime().exec("taskList");
Scanner in = new Scanner(process.getInputStream());
int count = 0;
while (in.hasNextLine()) {
count++;
String temp = in.nextLine();
if (temp.contains(task)) {
String[] t = temp.split(" ");
// 判断该进程所占内存是否大于20M
if (Integer.parseInt(t[t.length - 2].replace(",", "")) > 20000) {