java – 如何获取exe文件生成的控制台输出?

不使用重定向文件(“>”,“>>”)
Process p = Runtime.getRuntime().exec("executable.exec");

BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));

String line;
while ((line = input.readLine()) != null) {
  System.out.println(line);
}
https://stackoverflow.com/questions/1251039/how-can-i-get-the-console-output-generated-by-a-exe-file

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:java – 如何获取exe文件生成的控制台输出?