code: public static void writeObjectToConfAsBase64(String key, Object obj, Configuration conf) throws IOException {
      ByteArrayOutputStream baos = null;
      GZIPOutputStream gos = null;
      ObjectOutputStream oos = null;
  
      try {
        baos = new ByteArrayOutputStream();
        gos = new GZIPOutputStream(baos);
        oos = new ObjectOutputStream(gos);
        oos.writeObject(obj);
      } finally {
        Closeables.close(oos, false);
        Closeables.close(gos, false);
        Closeables.close(baos, false);
      }
  
      conf.set(key, new String(Base64.encodeBase64(baos.toByteArray()), Charsets.UTF_8));
    }
docs: Writes an object into a configuration by converting it to a base64 encoded string.
  This is done by serializing the object to bytes via an {@link ObjectOutputStream},
  gzip compressing those bytes, and then base64 encoding the compressed bytes.
  
  NOTE: obj must implement {@link java.io.Serializable}
  
  @param key for the configuration
  @param obj to write (must be Serializable)
  @param conf to write to
  @throws IOException