Read from Process only works when the process has exited
<p>I created a sub Process and I'm trying to read it output and print it. The process is a very simple python program that prints "Tick" every second and after some time exits.</p>

<p>The java code is:</p>

<pre><code>[..]
    try
    {
        ProcessBuilder pb = new ProcessBuilder(command);
        pb.redirectErrorStream(true);
        Process p = pb.start();

        InputStreamReader in = new InputStreamReader(p.getInputStream());
        BufferedReader br = new BufferedReader(in);

        String line;

        while ((line = br.readLine()) != null)
        {
            System.out.println(line);
            System.out.flush();
        }
    }
    catch (Exception ex)
    {
        System.out.println(ex.getMessage());
        System.exit(1);
    }
[..]
</code></pre>

<p>I only see the output on the console once the python program has exited. How can I read and print at the same time? Thanks</p>
