public static void writeStringListToConfAsBase64 ( String key , List < String > list , Configuration conf ) { Preconditions . checkNotNull ( list ) ; Iterator < String > iter = list . iterator ( ) ; StringBuilder sb = new StringBuilder ( ) ; while ( iter . hasNext ( ) ) { byte [ ] bytes = Base64 . encodeBase64 ( iter . next ( ) . getBytes ( Charsets . UTF_8 ) , false ) ; sb . append ( new String ( bytes , Charsets . UTF_8 ) ) ; if ( iter . hasNext ( ) ) { sb . append ( ' ' ) ; } } conf . set ( key , sb . toString ( ) ) ; }
Writes a list of strings into a configuration by base64 encoding them and separating them with commas