code: public void writeToStream(OutputStream stream, Object object) throws SerializationException {
          try {
              mapper.writeValue(stream, object);
          } catch (IOException ex) {
              throw new SerializationException("Exception during serialization", ex);
          }
      }
docs: Write the object to the stream.
  
  @param stream the stream to write the object to.
  @param object the object to write to the stream.
  @throws SerializationException the object could not be serialized.