Article View: borland.public.jbuilder.java.api
Article #159reading standard output
From: George
Date: Mon, 21 Jun 2004 20:22
Date: Mon, 21 Jun 2004 20:22
19 lines
1810 bytes
1810 bytes
I want to capture the standard output of a console program written in C in a
JTextArea component. The code I am running is shown below. The issue I
have is: it takes inordinately long for the the first line of output to
appear; and when it does all of the ouput (about 20 lines) appears together.
This is not the case if I run the program from the DOS prompt. Any ideas
why the behavior is different when the program is run under control of a
Java program?
cycleProcess = rt.exec(command, null, currentDir);
InputStreamReader isr = new
InputStreamReader(cycleProcess.getInputStream());
batchLogReader = new LineNumberReader(isr);
outputLine = batchLogReader.readLine();
while (outputLine != null) {
outputLine = batchLogReader.readLine();
messagesTextArea.setText(messagesTextArea.getText() + "\n" +
outputLine);
messagesTextArea.paintImmediately(messagesTextArea.getBounds());
}
Technical Details
Message-ID:
<40d74327@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,62c0f62159aba6f6,start X-Google-Attributes: gid1089d0,public From: "George" <geo_54321@yahoo.com> Newsgroups: borland.public.jbuilder.java.api Subject: reading standard output Date: Mon, 21 Jun 2004 16:22:35 -0400 Lines: 21 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 63.119.115.129 Message-ID: <40d74327@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1087849255 63.119.115.129 (21 Jun 2004 13:20:55 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail