Scanner does not read text file in run mode
<p>i am trying to deal with this problem without much success. Hope for some help.<br>
From inside my Java program, I am calling an outside executable, which upon completion creates a text (ASCII) file. I am using</p>

<p><code>Process p = Runtime.getRuntime().exec("....exe");</code></p>

<p>Next, I am asking for it to complete before switching 
(int exitValue = p.waitFor();) <br> and make sure that exit value is 0.</p>

<p>Right after that, I am creating a Scanner object to read the newly created file:</p>

<pre><code>File outputFile = new File(outputFileName);
Scanner scan = new Scanner(outputFile);
</code></pre>

<p>The file resides in the same folder as the executable, but I am passing a full path to it anyway. <br>
When I check if I can read the file (<code>outputFile.canRead()</code>), the answer is true. <br>
When I check the length of the file, it returns to me some number > 0, i.e., 440827.<br>
However, when I try to call <code>scan.hasNextLine()</code> or even <code>scan.hasNext()</code>, the answer is negative.<br>
An interesting fact is that when I run this in NetBeans debug mode, everything works fine. So, my guess is that i am in some sort of a race condition even though I am making precautions to not interrupt the Process's thread.
I tried to insert <code>Thread.sleep()</code> statements before calling <code>nextLine()</code>, but no result.<br>
Any suggestions, please?</p>
