I'm writing a Java program that is used to call a PHP script in set intervals. The PHP script outputs a lot of data, and it is the client's requirement that the Java program displays all the PHP script's output while the script runs.
The method I'm using is:
Runtime.getRuntime().exec(new String[]{"php", "file.php"});
Then using an InputStreamReader to grab output, primarily using examples from here. The problem I'm having is that the stream reader only outputs the data once the PHP script exits (which makes sense considering how the output is looped through).
How would I go about printing the script's output live while the script is running?
ProcessBuilderto construct theProcess. It allows easy merging of theSystem.out&System.err. +1 on referring to the Java World article. Since it solves 60% of questions where people don't mention it, I feel compelled to link. ;)ProcessBuilder.redirectOutput()to a file and trying to tail it