public static void putObjectToStream(Object obj,OutputStream os) throws IOException {
  ObjectOutputStream oos=new ObjectOutputStream(os);
  oos.writeObject(obj);
  oos.flush();
  oos.close();
}

public static void putObjectToStream ( Object obj , OutputStream os ) throws IOException { ObjectOutputStream oos = new ObjectOutputStream ( os ) ; oos . writeObject ( obj ) ; oos . flush ( ) ; oos . close ( ) ; }
serializes specified object to an output stream .
