public static void writeObjectToConfAsBase64(String key, Object obj, Configuration conf) throws IOException {
    try(ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
      try(GZIPOutputStream gos = new GZIPOutputStream(baos);
            ObjectOutputStream oos = new ObjectOutputStream(gos)) {
        oos.writeObject(obj);
      }
      conf.set(key, new String(Base64.encodeBase64(baos.toByteArray()), StandardCharsets.UTF_8));
    }
  }
public static void writeObjectToConfAsBase64 ( String key , Object obj , Configuration conf ) throws IOException { try ( ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ) { try ( GZIPOutputStream gos = new GZIPOutputStream ( baos ) ; ObjectOutputStream oos = new ObjectOutputStream ( gos ) ) { oos . writeObject ( obj ) ; } conf . set ( key , new String ( Base64 . encodeBase64 ( baos . toByteArray ( ) ) , StandardCharsets . UTF_8 ) ) ; } }
Writes an object to a configuration.

@param key for the configuration
@param obj the object to write
@param conf to read from
@throws IOException if there is an error while writing