code: public static void save(Object o, OutputStream stream) {
          try {
              ObjectOutputStream outStream = 
                  (stream instanceof ObjectOutputStream)
                      ? (ObjectOutputStream)stream
                      : new ObjectOutputStream(stream);
              outStream.writeObject(o);
          } catch (IOException ioe) {
              throw new IOError(ioe);
          }
      }
docs: Serializes the object to the provided stream.  This method does not close
  the stream after writing.
  
  @param o the object to be stored in the file
  @param stream the stream in which the object should be stored