Conflict using file.available() to show progress of in.readObject() reading one large Object
<p>I have a single large Object (about 20MB) I sometimes write to or read from disk.  There are no problems doing this and waiting for completion but it takes about a minute and I like to show whats happening using a progress bar.</p>

<p>My read code is as follows:</p>

<pre><code>InputStream file = new FileInputStream(filename);

// start a thread using file.available() to update a progress bar...
InputStream buffer = new BufferedInputStream(file);
ObjectInputStream in = new ObjectInputStream(buffer);           
site = (Site) in.readObject();
in.close(); 
buffer.close();
file.close();
</code></pre>

<p>It all works fine so long as I don't call <code>file.available()</code> continuously without pause.  It would seem that calling <code>file.available()</code> while <code>in.readObject()</code> is active can sometimes cause a conflict.  Putting in a delay seems a foolish fudge.  Please can someone tell me the correct way of doing this.</p>
