java运行本地命令 java 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不会Linux啊,前几天无聊的时候,写着玩的,不知道对楼主有没有帮助try { // 获取所有进程 Process process = Runtime.getRuntime().exec("tasklist"); Scanner in = new Scanner(process.getInputStream()); while (in.hasNextLine()) { String p = in.nextLine(); // p的效果 // notepad.exe 1028 Console 1 6,884 K if (p.contains(PROCESS)) { StringBuffer buf = new StringBuffer(); // buf的效果 // notepad.exe1028Console16,884K for (int i = 0; i < p.length(); i++) { char ch = p.charAt(i); if (ch != ' ') { buf.append(ch); } } // 截出notepad.exe的PID int pid = Integer .parseInt(buf.toString().split("Console")[0] .substring(PROCESS.length())); // 强制结束进程 Runtime.getRuntime().exec("taskkill /pid " + pid + " /f"); } } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }楼主看看用Scanner 行不行 如何在 JPopupMenu 中添加一个滚动条? 问一个关于int转化为byte的问题, java Unicode问题 JSpinner如何格式化输入?就是限制输入数据的范围,参与有分 如何从vector中取出数组? sun或者有没有专门对IP地址检查的工具类 新手问题,怎么使用TimerTask,最好能给个例子。 EJB开发中的问题! 怎么把JBuilder自带的JDK 1.3换成 JDK 1.4? 我引入了一个pinyin4j-2.5.0.jar包,为什么有的类能引用,有的不能?!都存在! JTextPane改变字体颜色的一个问题 一个日志文件过大,要如何读取,才可以保证不会出现内存溢出
try {
// 获取所有进程
Process process = Runtime.getRuntime().exec("tasklist");
Scanner in = new Scanner(process.getInputStream());
while (in.hasNextLine()) {
String p = in.nextLine(); // p的效果
// notepad.exe 1028 Console 1 6,884 K
if (p.contains(PROCESS)) { StringBuffer buf = new StringBuffer();
// buf的效果
// notepad.exe1028Console16,884K
for (int i = 0; i < p.length(); i++) {
char ch = p.charAt(i);
if (ch != ' ') {
buf.append(ch);
}
}
// 截出notepad.exe的PID
int pid = Integer
.parseInt(buf.toString().split("Console")[0]
.substring(PROCESS.length()));
// 强制结束进程
Runtime.getRuntime().exec("taskkill /pid " + pid + " /f"); }
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}楼主看看用Scanner 行不行