I'm accessing to running exe using below method. But I want to get the count of running exe files. Basically I want to get the count of exe process currently runs. Other than assigning all the process name to a list is there a simple way to obtain the count.
public boolean isProcessRunning(String serviceName) {
try {
Process pro = Runtime.getRuntime().exec(TASKLIST);
BufferedReader reader = new BufferedReader(new InputStreamReader(pro.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
// System.out.println(line);
if (line.startsWith(serviceName)) {
return true;
}
}
} catch (IOException e) {
e.printStackTrace();
}
return false;
}