用 Java 执行外部命令 (例)

public static void main(String[] args) {
try {

Process proc = Runtime.getRuntime().exec("taskkill /IM iexplore.exe");

while (proc.getInputStream().read() != -1) ;
while (proc.getErrorStream().read() != -1) ;

proc.waitFor();

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

留下评论

您的邮箱地址不会被公开。 必填项已用 * 标注