Does someone know how I can convert an Shape3D to an byte array (and back)?

I allready tried to use a "ByteArrayOutputStream" with an "ObjectOutputStream", but that didn't work.

Sample code:
Java Code:
Shape3D s = new Shape3D();
byte[] b = convertToBytes(s); // unknow function
Shape3D newS = convertToShape3D(b); // unknow function
Can someone help me please?

Thanks,
Dennis