public class Batch {
public static void main(String[] args) throws Exception {
executeBatch();
}
private static void executeBatch() {
BufferedReader in = null;
Runtime r = Runtime.getRuntime();
Process proc;
String command = "./batch.bat";
String line = null;
try {
proc = r.exec(command);
in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
while ((line = in.readLine()) != null) {
System.out.println("LINE:" + line);
}
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
// batch.bat
echo hahaha
echo sdfd