Note that there are some explanatory texts on larger screens.

plurals
  1. POAppending to ObjectOutputStream (writing multiple objects w/o closing stream)
    text
    copied!<p>Desclaimer My question is different from two following links</p> <p><a href="https://stackoverflow.com/questions/1194656/appending-to-an-objectoutputstream">Question 1</a></p> <p><a href="https://stackoverflow.com/questions/4646272/appending-objects-to-a-binary-file">Question 2</a></p> <pre><code> public class AppendableObjectOutputStream extends ObjectOutputStream { public AppendableObjectOutputStream(OutputStream out) throws IOException { super(out); } @Override protected void writeStreamHeader() throws IOException {} } </code></pre> <ul> <li>The problem with above solutions is that they do not support writing multiple objects to appendable stream w/o closing the stream. </li> <li>If I open appendable stream, write multiple objects - then at time of reading I can read only first object properly and on trying to read second object, I get EOF exception.</li> <li><p>If I proceed the way like write on object to appendable stream, close stream. Then again open stream, write another object close and so on. This way I am able to read multiple objects properly.</p> <pre><code> fileOutputStream = new FileOutputStream("abc.dat",true); outputBuffer = new BufferedOutputStream(fileOutputStream); objectStream = new AppendableObjectOutputStream(outputBuffer); BucketUpdate b1 = new BucketUpdate("getAllProducts1",null,"1",null); BucketUpdate b2 = new BucketUpdate("getAllProducts2",null,"2",null); BucketUpdate b3 = new BucketUpdate("getAllProducts3",null,"3",null); objectStream.writeObject(b1); objectStream.writeObject(b2); objectStream.writeObject(b3); objectStream.close(); </code></pre></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload