Example usage for org.springframework.core.io.support PropertiesLoaderUtils fillProperties

List of usage examples for org.springframework.core.io.support PropertiesLoaderUtils fillProperties

Introduction

In this page you can find the example usage for org.springframework.core.io.support PropertiesLoaderUtils fillProperties.

Prototype

static void fillProperties(Properties props, EncodedResource resource, PropertiesPersister persister)
        throws IOException 

Source Link

Document

Actually load properties from the given EncodedResource into the given Properties instance.

Usage

From source file:org.springframework.core.io.support.PropertiesLoaderSupport.java

/**
 * Load properties into the given instance.
 * @param props the Properties instance to load into
 * @throws IOException in case of I/O errors
 * @see #setLocations//  w ww.  j a  va  2  s.  c  o  m
 */
protected void loadProperties(Properties props) throws IOException {
    if (this.locations != null) {
        for (Resource location : this.locations) {
            if (logger.isDebugEnabled()) {
                logger.debug("Loading properties file from " + location);
            }
            try {
                PropertiesLoaderUtils.fillProperties(props, new EncodedResource(location, this.fileEncoding),
                        this.propertiesPersister);
            } catch (FileNotFoundException | UnknownHostException ex) {
                if (this.ignoreResourceNotFound) {
                    if (logger.isInfoEnabled()) {
                        logger.info("Properties resource not found: " + ex.getMessage());
                    }
                } else {
                    throw ex;
                }
            }
        }
    }
}