我正在编写一个Swing应用程序,它将执行长期运行的perl脚本。我需要同时显示执行的临时输出,即使进程在后台执行。使用下面的代码在进程完成时返回输出。
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
// read the output from the command
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}我怎样才能同时得到输出?我使用Swingworker显示返回的信息。
发布于 2013-08-29 11:22:00
Perl端是否启用了自动刷新?如果没有,那你就会缓冲。
通过$|++;或$| = 1;将$|++;设置为非零值,以启用自动刷新。
有关更多详细信息,请参阅perldoc perlvar。
https://stackoverflow.com/questions/18509236
复制相似问题