OutputStream with ByteArrayOutputStream not writing

Posted by Yonatan on Stack Overflow See other posts from Stack Overflow or by Yonatan
Published on 2010-05-28T06:25:53Z Indexed on 2010/05/28 6:31 UTC
Read the original article Hit count: 295

Filed under:
|
|

Hey again Internet !

So i'm trying to write out an object to a ByteArray, but for some reason it's not writting anything, which i see by the fact that the return value is 0, and that by the fact that reading it results in an exception.

BAoutput = new ByteArrayOutputStream();  
Oout = new ObjectOutputStream(BAoutput);  
Oout.writeObject(receiver);

where receiver is an object i get through a parameter. and the exceptions are always the same:

at java.io.ObjectInputStream$BlockDataInputStream.peekByte(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)

Any ideas?

© Stack Overflow or respective owner

Related posts about java

Related posts about serialization