新手提问----帮我看看这个代码错在哪里,怎么改
程序代码:
import javax.swing.JOptionPane; public class tss { /** * @param args */ private static int tasklist1 = -1; public static void main(String[] args) { try { String cmd1 = "cmd.exe /c tasklist"; p =Runtime.getRuntime().exec(cmd1); StringBuffer out = new StringBuffer(); byte[] b = new byte[1024]; for (int n; (n = p.getInputStream().read(b)) != -1;) { out.append(new String(b, 0, n)); } tasklist1=out.toString().indexOf("QQ.exe");//检查QQ进程 } catch (Exception e1) { e1.printStackTrace(); } if(tasklist1==-1){ //程序在进程中没有发现 }else{ JOptionPane.showMessageDialog(null, "程序已经打开!", "警告", 1); } } }