I am trying to read real-time the data from a process using a BufferedReader and redirect it to a TextArea. However, I have noticed that when the process is running the .bat, it tends to freeze and cause a lag to the JavaFX TextArea. The ".bat" fiel that runs prints out a .....
one one line to indicate progress, and I believe this is where it is failing at.
I had an idea to have the program wait a certain amount of time, then it executes, but because its all on one line it also fails. Please help
Code:
while(iterator.hasNext()) {
Map.Entry mentry = (Map.Entry)iterator.next();
String taskPath = " /k d: && cd DATA\\Virtualization\\Users && ESXRun.bat";
ProcessBuilder pb = new ProcessBuilder("cmd",taskPath);
Process process = pb.start();
BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
String s = "";
// read the output from the command
while ((s = stdInput.readLine()) != null) {
//TextArea
cliLog.appendText(s);
cliLog.appendText("\n");
}
process.waitFor();
process.destroy();
}