When I run the python script, the output appears in DOS (command line on Windows).
I want the output to be displayed in a JAVA application, i.e. in the window that corresponds to JTextArea. The output should be the same as on DOS.
So, How can I make a conclusion from DOS and paste it into a JAVA application?
(I tried to save the output of the python script in a text file and then read it using JAVA. But in this case, the JAVA application expects the script to finish first and then display the output. And, when the output is larger than the screen size, the scroll bar fits, so I can see the whole output.)
After re-commenting, I ran this code. but the output is always:
error: The process said:
import java.io.*;
import java.lang.*;
import java.util.*;
class useGobbler {
public static void main ( String args[] )
{
ProcessBuilder pb;
Process p;
Reader r;
StringBuilder sb;
int ch;
sb = new StringBuilder(2000);
try
{
pb = new ProcessBuilder("python","printHello.py");
p = pb.start();
r = new InputStreamReader(p.getInputStream());
while((ch =r.read() ) != -1)
{
sb.append((char)ch);
}
}
catch(IOException e)
{
System.out.println("error");
}
System.out.println("Process said:" + sb);
}
}
- , ?