简体   繁体   中英

Capturing command-line output using Java

Process process = Runtime.getRuntime().exec("C:/chess/h.exe");
Scanner scanner = new Scanner(process.getInputStream());
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
writer.write("uci");
while (true) System.out.println(scanner.nextLine());

It writes:

 Houdini 4 Pro x64 (c) 2013 Robert Houdart

 info string 4 processor(s) found info string NUMA configuration with 1
 node(s), offset 0 info string 128 MB Hash

If I doing the same in console, the result is 在此处输入图片说明

Where did other text dissapeared? How can I make it been seen using my program?

也尝试捕获错误输出,可能是h.exe程序仅将“ info”消息打印到标准输出,而其他所有内容都发送到错误输出的情况。

process.getErrorStream();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM