code: public static <T extends Serializable> void serializeToStream(T obj, OutputStream out) throws IOException
  	{
  		ObjectOutputStream objOut;
  
  		if(out instanceof ObjectOutputStream)
  			objOut = (ObjectOutputStream)out;
  		else
  			objOut = new ObjectOutputStream(out);
  		objOut.writeObject(obj);
  		objOut.close();
  	}
docs: Write one object serilized to a output stream.
  @param obj The Object to serilize.
  @param out The output stream to write it to. This will be closed!