java如何获取本地操作系统进程列表
作者:alonelywolf 时间:2022-12-05 13:35:20
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 {
// 创建系统进程
ProcessBuilder pb = new ProcessBuilder("tasklist");
Process p = pb.start();
BufferedReader out = new BufferedReader(new InputStreamReader(new BufferedInputStream(p.getInputStream()), Charset.forName("GB2312")));
BufferedReader err = new BufferedReader(new InputStreamReader(new BufferedInputStream(p.getErrorStream())));
System.out.println("Window 系统进程列表");
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);
}
}
}
控制台输出:
标签:java,操作系统,进程
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
IDEA如何进行全局搜索图文教程
2022-10-14 13:39:45
![](https://img.aspxhome.com/file/2023/4/63684_0s.jpg)
C#使用HttpPost请求调用WebService的方法
2022-02-24 07:22:16
![](https://img.aspxhome.com/file/2023/8/89848_0s.png)
Android如何实现非本地图片的点击态
2023-06-16 00:21:16
Flutter利用Hero组件实现自定义路径效果的动画
2023-06-25 13:46:29
![](https://img.aspxhome.com/file/2023/3/85453_0s.png)
Java Integer及int装箱拆箱对比
2023-04-22 04:21:11
漂亮的Android音乐歌词控件 仿网易云音乐滑动效果
2022-01-26 14:16:25
![](https://img.aspxhome.com/file/2023/2/114292_0s.gif)
c# 实现语音聊天的实战示例
2021-11-18 06:29:20
![](https://img.aspxhome.com/file/2023/2/91312_0s.png)
C#中的尾递归与Continuation详解
2022-07-27 04:14:05
JAVA提高第八篇 动态代理技术
2023-07-19 07:13:12
![](https://img.aspxhome.com/file/2023/9/62829_0s.jpg)
完美解决c# distinct不好用的问题
2023-02-13 11:22:53
Android实现短信验证功能的代码
2022-08-28 19:54:15
![](https://img.aspxhome.com/file/2023/2/123292_0s.gif)
RabbitMQ交换机使用场景和消息可靠性总结分析
2023-10-06 14:00:55
Spring集成MyBatis 及Aop分页的实现代码
2022-01-06 14:30:47
![](https://img.aspxhome.com/file/2023/5/64785_0s.png)
Unity的OnOpenAsset实用案例深入解析
2021-05-30 01:37:16
Android中LayoutInflater.inflater()的正确打开方式
2022-04-12 16:25:57
详解android异步更新UI的几种方法
2022-03-07 08:27:22
浅谈Java8 判空新写法
2023-06-21 15:55:08
![](https://img.aspxhome.com/file/2023/2/75712_0s.jpg)
java异步上传图片示例
2023-05-31 13:42:51
IntelliJ IDEA使用教程从入门到上瘾(2019图文版)
2023-03-30 17:00:49
![](https://img.aspxhome.com/file/2023/8/92678_0s.png)
Mybatis中的resultType和resultMap查询操作实例详解
2022-02-24 17:05:42
![](https://img.aspxhome.com/file/2023/3/76233_0s.png)