/*
* 【JAVA中執行bat】
>test.bat
haha
exit 99
>RuntimeTest.java
*
*
*
*/
public class RuntimeTest {
public static void main(String[] args) {
try {
Process process=Runtime.getRuntime().exec("test.bat");
StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "ERROR");
// kick off stderr
errorGobbler.start();
StreamGobbler outGobbler = new StreamGobbler(process.getInputStream(), "STDOUT");
// kick off stdout
outGobbler.start();
process.waitFor();
System.out.println(process.exitValue());
} catch(Exception e) {}
}
}