java有一种保持测试的方法。Bat文件打开并运行其余的代码?
我有下面的代码-执行批处理文件,但程序不会执行其余的代码,而是留在批处理文件本身。 我想要实现的是让这个批处理文件在其余代码执行时运行
public class CmdJava {
public static void main(String[] args) throws IOException {
Process p = Runtime.getRuntime().exec("cmd /c call README.bat");
String s;
System.out.println(p.getOutputStream());
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
//code reaches and stops at this line as the batch file need to be forcefully closed
}
System.out.print("Need to reach this code");
}
}
非常感谢您的帮助
共 (0) 个答案