详细的调用代码如下:
public class EXEUtil {
public static final String EXE_NAME = "RollBackDo.exe";
/**
*
* @param arg0 第1个参数
* @param arg1 第2个参数
* @return -1,程序发生异常。
* 如果在命令行,则应该类似这样 : command 1 2
* 成功返回0,并在vixtel的bin\xml的目录下生成对应的xml文件
* @anthor daimami.com
*/
public static int invokeExeWithParas(String arg0,String arg1){
Runtime runtime = Runtime.getRuntime();
try {
String[] cmd = {Consts.PROPERTIES_DLL_DIR + "/" + EXE_NAME,arg0,arg1};
Process process = runtime.exec(cmd);
int retValue = process.waitFor();
System.out.print("exe 程序返回的代码:");
System.out.println(retValue);
BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
System.out.println("程序返回的信息");
while ((line = input.readLine()) != null) {
System.out.println(line);
}
input.close();
return retValue;
}
catch (IOException e) {
e.printStackTrace();
}
catch (InterruptedException e) {
e.printStackTrace();
}
return -1;
}
}