public byte[] toBytes(T object) {
        try {
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            ObjectOutputStream out = new ObjectOutputStream(stream);
            out.writeObject(object);
            return stream.toByteArray();
        } catch(IOException e) {
            throw new SerializationException(e);
        }
    }
public byte [ ] toBytes ( T object ) { try { ByteArrayOutputStream stream = new ByteArrayOutputStream ( ) ; ObjectOutputStream out = new ObjectOutputStream ( stream ) ; out . writeObject ( object ) ; return stream . toByteArray ( ) ; } catch ( IOException e ) { throw new SerializationException ( e ) ; } }
Transform the given object into an array of bytes

@param object The object to be serialized
@return The bytes created from serializing the object