ruleSet.addRule( rule1 );
ruleSet.addRule( rule2 );
// Serialize to a byte array
ByteArrayOutputStream bos = new ByteArrayOutputStream( );
ObjectOutput out = new ObjectOutputStream( bos );
out.writeObject( ruleSet );
out.close( );
// Get the bytes of the serialized object
byte[] bytes = bos.toByteArray( );
// Deserialize from a byte array