I have created an ObjectOutputStream
ObjectOutputStream stream = new ObjectOutputStream(new ByteArrayOutputStream());
stream.writeObject(myObject);
but how do I now convert this back into an Object
, or even a ByteArray
?
I've tried getting an ObjectInputStream
like this
ByteArrayOutputStream outputStream = (ByteArrayOutputStream) myProcess.getOutputStream();
final ObjectInputStream objectInputStream = new ObjectInputStream(
new ByteArrayInputStream(outputStream.toByteArray()));
however I get a compile error saying it can't cast the ObjectOutputStream
to a ByteArrayOutputStream
; yet there seem to be no methods on the ObjectOutputStream
to get the data back?