public static byte [ ] objectToBytes ( Object object ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; ObjectOutputStream os = new ObjectOutputStream ( baos ) ; os . writeObject ( object ) ; return baos . toByteArray ( ) ; }
Converts a serializable object to a byte array .