Package com.wa.xwolf.sblog.util;
Import Java.io.BufferedInputStream;
Import Java.io.BufferedReader;
Import Java.io.InputStreamReader;
Import Java.nio.charset.Charset;
public class Processutil {public
static void Main (string[] args) throws Exception {
//Create system process
Processbuilder PB = new Processbuilder ("tasklist");
Process p = Pb.start ();
BufferedReader out = new BufferedReader (New InputStreamReader (P.getinputstream ()), Charset.forname ("GB2312"));
BufferedReader err = new BufferedReader (new InputStreamReader (New Bufferedinputstream (P.geterrorstream ()));
SYSTEM.OUT.PRINTLN ("Window System process List");
String Ostr;
while ((Ostr = Out.readline ())!= null)
System.out.println (OSTR);
String estr = Err.readline ();
if (estr!= null) {
System.out.println ("\nerror Info");
System.out.println (ESTR);}}
Console output:
The above is the entire content of this article, I hope you can master Java get the local operating system process list method.