static void interceptLoadingFiles ( Properties props ) throws IOException { Logger logger = Logger . getLogger ( UserDataHelpers . class . getName ( ) ) ; Set < String > keys = props . stringPropertyNames ( ) ; for ( final String key : keys ) { if ( ! key . startsWith ( ENCODE_FILE_CONTENT_PREFIX ) ) continue ; String realKey = key . substring ( ENCODE_FILE_CONTENT_PREFIX . length ( ) ) ; String value = props . getProperty ( realKey ) ; if ( value == null ) { logger . fine ( "No file was specified for " + realKey + ". Skipping it..." ) ; continue ; } File f = new File ( value ) ; if ( ! f . exists ( ) ) throw new IOException ( "File " + f + " was not found." ) ; // Read the file content as bytes ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ; Utils . copyStream ( f , os ) ; String encodedFileContent = encodeToBase64 ( os . toByteArray ( ) ) ; props . put ( key , encodedFileContent ) ; } }
Intercepts the properties and loads file contents .