I am trying to run an external Java program and read the output. The program is a C ++ Linux application that runs a data mining algorithm and prints samples found on standard output. I want to be able to read this output from my Java application and show patterns using a table. The problem is that the output size is quite large (as a test, it produces 6.5 MB in 30 seconds). I use ProcessBuilder and read the output using an InputStreamReader buffered using a BufferedReader, as you can see in the following code:
String[] cmd = {"./clogen_periodic", selected, support, "-t 4"};
Process p = new ProcessBuilder(cmd).start();
input = new BufferedReader (new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
...
process line;
...
}
The problem is that the result is damaged. When I run the same program on the console, the output is correct, but when I use the Java application, some lines are concatenated. More precisely, the output should be like this:
TMEmulation log_pseduo_allocation (34985) (2 45 76 89 90)
__divw clock timer (8273) (4 6 67 4 2)
but it looks like
TMEmulation log_pseduo_allocation (34985) (2__divw 45clock 76timer (89 8273) 904) (6 67 4 2)
Any idea on a possible problem?
Thank you very much in advance, Patricia
source
share