getting stdout into Swing textArea - TechRepublic
General discussion
May 14, 2001 at 09:07 AM
orhan.duyar

getting stdout into Swing textArea

by orhan.duyar . Updated 24 years, 11 months ago

I am trying to run unix operating system command or shell script within my java program and get the stdout displayed into my textArea. It works fine. The problem I am having is I don’t get anything show up on my textArea until all the output is ready. In other words, if the output lasts two minutes, and if I send the output to Systen.out.println(s) I get the output line by line, the way I want it, but if I try to get it into my textArea I have to wait for two minutes, and I get all output at once.

Here is my code

Process p = Runtime.getRuntime().exec(l);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((s = stdInput.readLine()) != null)
{
pane.append(s);
pane.append(“\”);
}

This discussion is locked

All Comments