ITPub博客

首页 > 应用开发 > Java > Java执行exe,bat等可执行文件

Java执行exe,bat等可执行文件

原创 Java 作者:iandshe 时间:2008-07-27 19:47:59 0 删除 编辑


Process proc = Runtime.getRuntime().exec(command);

[@more@]

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class CallExe {
public static void main(String[] args) {
String text = null;
String command = "C:Program FilesYodaoDeskDictRunDict.exe";//exe,bat文件名OR DOS命令
try {
Process proc = Runtime.getRuntime().exec(command);
BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
while ((text = in.readLine())!= null) {
System.out.println(text); //输出测试
}
} catch (IOException ioError) {
ioError.printStackTrace();
System.exit(0);
}

}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7313961/viewspace-1007942/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论
  • 博文量
    4
  • 访问量
    15824