public static void write(OutputStream stream,Object o) throws Exception {
  ObjectOutputStream oos;
  if (!(stream instanceof BufferedOutputStream)) {
    stream=new BufferedOutputStream(stream);
  }
  oos=new ObjectOutputStream(stream);
  oos.writeObject(o);
  oos.flush();
  oos.close();
}

public static void write ( OutputStream stream , Object o ) throws Exception { ObjectOutputStream oos ; if ( ! ( stream instanceof BufferedOutputStream ) ) { stream = new BufferedOutputStream ( stream ) ; } oos = new ObjectOutputStream ( stream ) ; oos . writeObject ( o ) ; oos . flush ( ) ; oos . close ( ) ; }
serializes the given object to the specified stream .
