public static Properties loadProperties ( String fileName ) { LowerCaseProperties properties = new LowerCaseProperties ( ) ; ClassLoader classLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; URL url = classLoader . getResource ( fileName ) ; // try opening from classpath if ( url != null ) { InputStream urlStream = null ; try { urlStream = url . openStream ( ) ; properties . load ( urlStream ) ; logger . info ( "Properties from classpath loaded file: " + fileName ) ; } catch ( IOException e ) { logger . info ( "Properties from classpath not loaded because file not found: " + fileName ) ; } finally { if ( urlStream != null ) { try { urlStream . close ( ) ; } catch ( IOException e ) { } } } } // Override properties found on the classpath with any found in a file // of the same name LowerCaseProperties propertiesFromFileSystem = loadProperties ( new File ( fileName ) ) ; properties . putAll ( propertiesFromFileSystem ) ; return properties ; }
load properties from file