title: Reading an object file written by ObjectOutputStream in append mode (multiple closings)
body: <p>I have written multiple objects in the same file over last 2 weeks. Each time (probably million times) I called:</p>
  
  <pre><code>try(ObjectOutputStream output=new ObjectOutputStream(new FileOutputStream(new File("somefile"),true))) {            
          output.writeObject(someobject);               
          output.close();
      } 
  </code></pre>
  
  <p>Now when I try to read it using:</p>
  
  <pre><code>try(ObjectInputStream input=new ObjectInputStream(new FileInputStream(new File("somefile")))) {   
          while(true) {     
              PROCESS_IT(input.readObject());
          }
      }
  </code></pre>
  
  <p>It reads only first object and gives error:</p>
  
  <pre><code>java.io.StreamCorruptedException: invalid type code: AC
  at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1379)
  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
  </code></pre>
  
  <p>I know now that I should have overridden the streamheader while writing these objects (<a href="https://stackoverflow.com/questions/1194656/appending-to-an-objectoutputstream?rq=1">Appending to an ObjectOutputStream</a>)</p>
  
  <p>But it took me <em>two weeks</em> already to get the results in this "somefile". <strong>Can I somehow still read all the objects by skipping the corrupt bytes/headers?</strong> 
  Please advise. Thanks</p>