Package Com.cmd.core;
Import Java.io.BufferedReader;
Import java.io.IOException;
Import Java.io.InputStream;
Import Java.io.InputStreamReader;
Import java.util.ArrayList;
Import java.util.List;
public class Streamgrabber extends Thread {
private final InputStream stream;
private final list<string> holder;
public Streamgrabber (InputStream stream) {
This (stream, null);
}
public Streamgrabber (InputStream stream, list<string> holder) {
this.stream = stream;
this.holder = holder;
}
@Override
public void run () {
try {
BufferedReader br = new BufferedReader (
new InputStreamReader (stream));
String line = null;
while (line = Br.readline ()) = null) {
if (holder! = NULL)
Holder.add (line);
}
} catch (IOException IoE) {
ioe.printstacktrace ();
}
}
public static Process performcommand (String command) {
try {
return Runtime.getruntime (). exec (command);
} catch (IOException e) {
e.printstacktrace ();
return null;
}
}
public static void Main (string[] args) {
//Notepa.exe Close Notepad process
String command = "taskkill/f/im 11Game.exe";
Process proc = performcommand (command);
list<string> outputs = new arraylist<string> ();
New Streamgrabber (Proc.getinputstream (), outputs). Start ();
}
}
Java implementation closes the process under the WinDOS system