java - 有没有办法让 test.Bat 文件保持打开并运行其余代码?
问题描述
我在下面有这段代码-执行批处理文件但程序不会执行其余代码,而是保留在批处理文件本身中。我想要实现的是在执行其余代码的同时运行此 BATCH 文件。
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");
}
}
任何帮助是极大的赞赏
解决方案
推荐阅读
- groovy - Groovy 中的 Switch 语句
- java - 屏幕解锁后无法强制我的应用程序自动启动
- python - Tkinter Listbox 人口返回空元组
- mysql - 选择具有相同值和时间间隔 MySQL 的行
- spring - Gradle 任务 runtimeOnlyDependenciesMetadata 失败
- docker - Windows 文件和文件夹的权限错误(包含在 docker 容器中)
- python - 使用 python 的不和谐机器人
- node.js - 如何在 web.config 中编写规则以通过更改域在子文件夹中启动另一个节点应用程序
- python - Colab 上的 Python 图像比较
- docker - 为什么 docker build 使用 --squash 创建中间映像