So i have this code which prints out the running processes from task manager to the ide in netbeans but i'd like to scan the output of processes so i can list the highest running process on my PC at the time?
public static void main(String[] args) throws IOException {
try {
String tasklist;
Process p = Runtime.getRuntime().exec
(System.getenv("windir") +"\\system32\\"+"tasklist.exe");
try (BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
while ((tasklist = input.readLine()) != null) {
System.out.println(tasklist); //<-- Parse data here.
}
}
} catch (IOException err) {
err.printStackTrace();
}
}
This give me the below output for example and if i'd like to kill netbeans because it's running over 500,000k how would i do that?
Image Name PID Session Name Session Mem Usage
chrome.exe 3464 Console 3 159,672 K
netbeans64.exe 3664 Console 3 592,216 K
chrome.exe 3808 Console 3 384,556 K
java.exe 2040 Console 3 36,732 K
tasklist.exe 2208 Console 3 6,196 K