/**
*
*/
package de.tutorials;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Scanner;
/**
* @author Thomas.Darimont
*
*/
public class ListCurrentTasksExample {
/**
* @param args
*/
public static void main(String[] args) throws Exception{
Process process = new ProcessBuilder().command("tasklist","/V").redirectErrorStream(true).start();
Scanner scanner = new Scanner(process.getInputStream());
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
while(scanner.hasNextLine()){
printWriter.println(scanner.nextLine());
}
System.out.println(stringWriter);
}
}