public static void serialize(Serializable obj,ByteArrayOutputStream bout){
  try {
    ObjectOutputStream out=new ObjectOutputStream(bout);
    out.writeObject(obj);
    out.close();
  }
 catch (  IOException e) {
    throw new IllegalStateException("Could not serialize " + obj,e);
  }
}

public static void serialize ( Serializable obj , ByteArrayOutputStream bout ) { try { ObjectOutputStream out = new ObjectOutputStream ( bout ) ; out . writeObject ( obj ) ; out . close ( ) ; } catch ( IOException e ) { throw new IllegalStateException ( "Could not serialize " + obj , e ) ; } }
serialize the given object into the given stream
