code: 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);
  		}
  	}
docs: Serialize the given object into the given stream