I'm trying to launch a process and then from the output update the UI with info from it. This is my current code:
ProcessBuilder pb = new ProcessBuilder()
.redirectErrorStream(true)
.command(args);
Process process = pb.start();
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null)
{
System.out.println(line.trim());
// Trying to update the UI here
}
The provlem is that the line gets outputted to the console, but the UI freezes and doesn't get updated. I assume it's because of the while loop, but how do I fix it?
Thanks!