java.io.StreamCorruptedException: invalid stream header: 41050000
<p>I am trying to test a program and for that I need to access ReadExternal function but I am getting StreamCorrupted exception on ObjectInputStream. 
I know I need to use the object written by WriteObject but dont know how to do it...</p>

<pre><code>ObjectOutputStream out=new ObjectOutputStream(new ByteArrayOutputStream());
    out.writeObject(ss3); 
    ss3.writeExternal(out);
    try{
         ByteInputStream bi=new ByteInputStream();
         bi.setBuf(bb);
         out.write(bb);
         ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bb));
         String s1=(String) in.readObject();
        }
        catch(Exception e){
            e.printStackTrace();
        }
</code></pre>
