Load properties from a resource stream.
@param propFileName The resource name.
495615
private void loadProperties(String propFileName) {
		if (propFileName != null) {
			loadProperties(getClass().getResourceAsStream(propFileName), propFileName);
		}
	}
83998
private void loadProperties(InputStream stream, String path) {
		if (stream == null) {
			return;
		}
		
		try {
			Properties props = new Properties();
			props.load(stream);
			
			Iterator<Object> keyIt = props.keySet().iterator();
			while (keyIt.hasNext()) {
				String key = keyIt.next().toString();
				_properties.put(key, props.get(key));
			}
		}
		catch (Exception e) {
			Console.warn("Unable to load properties file ["+path+"].");
		}
		finally {
			if (stream != null) {
				try {
					stream.close();
				}
				catch (Exception e) {
					Console.warn("Unable to close properties file ["+path+"].");
				}
			}
		}
	}
419753
public void loadProperties(String prefix) {
        List<Property> props = null;
        
        try {
            props = getListByPrefix(prefix);
        } catch (Exception e) {
            log.error("Error retrieving properties with prefix: " + prefix, e);
            return;
        }
        
        for (Property prop : props) {
            if (prop.getName() != null) {
                this.properties.put(prop.getName(), prop);
            }
        }
    }
1093284
private synchronized void loadProperties()
	{
		// If multiple threads are waiting to invoke this method only allow
		// the first one to do so. The rest should just return since the first
		// thread through took care of loading the properties.
		try
		{
			
			this.file = null;
			
			boolean alwaysReload = this.isAlwaysReload();

			boolean useFormatting = this.isUseFormatting();
	
			String filePath = getSystemPropertyFile();
			if (filePath != null && filePath.length() > 0)
			{
				// System.out.println("CONFIG: LOADING CONFIG properties from "+
				// file);
				this.file = Paths.get(filePath).toFile();
				FileInputStream fis = new FileInputStream(file);

				try
				{
					properties = new Properties();
					// Load the properties object from the properties file
					properties.load(fis);
					// System.out.println("CONFIG: FINISHED LOADING CONFIG
					// properties from "+
					// file);

					configSourceLocation = file.getAbsolutePath();
				}
				catch (Exception e)
				{
					e.printStackTrace();
					throw new ConfigException(e.toString());
				}
				finally
				{
					if (fis != null)
						fis.close(); // Always close the file, even on exception

				}

			}
			else
			{
				properties = new Properties();

				try
				{
					String bundleName = getBundleName();

					// try to get properties from resource bundle
					ResourceBundle rb = ResourceBundle.getBundle(bundleName);

					URL url = Config.class.getResource(bundleName + ".properties");

					if (url != null)
						configSourceLocation = url.toString();
					else
						configSourceLocation = bundleName + ".properties";

					Enumeration<?> keys = rb.getKeys();

					Object k = null;

					while (keys.hasMoreElements())
					{

						k = keys.nextElement();

						properties.put(k, rb.getString(k + ""));

					}
				} // end els load from resource bundle
				catch (MissingResourceException e)
				{
				}
			}//end else
			
			

			//Determine global settings
			String reloadBool = properties.getProperty(Config.class.getName() + ".alwaysReload");

			if (reloadBool == null || reloadBool.length() == 0)
			{

				// throw new ConfigException("System property
				// "+Constants.ALWAY_RELOAD_PROP+" is not set.");

				alwaysReload = false;

			}
			else
			{
				alwaysReload = Boolean.valueOf(reloadBool).booleanValue();
			}

			this.setAlwaysReload(alwaysReload);

			// Merge SystemProperteis
			mergeSystemProperties = Boolean
					.valueOf(properties.getProperty(Config.class.getName() + ".mergeSystemProperties", "true"))
					.booleanValue();

			if (mergeSystemProperties)
			{
				// add system properties
				properties.putAll((Properties)System.getProperties().clone());
			}

			// Envinronment SystemProperteis
			mergeEnvProperties = Boolean
					.valueOf(properties.getProperty(Config.class.getName() + ".mergeEnvProperties", "true"))
					.booleanValue();

			if (mergeEnvProperties)
			{
				// add env properties
				properties.putAll(System.getenv());
			}

			// process formatting
			String propName = Config.class.getName() + ".useFormatting";
			String useFormattingText = properties.getProperty(propName);

			// System.out.println("CONFIG:
			// "+propName+"="+useFormattingText);

			if (useFormattingText == null || useFormattingText.length() == 0)
			{

				// throw new ConfigException("System property
				// "+Constants.ALWAY_RELOAD_PROP+" is not set.");

				useFormatting = false;

			}
			else
			{
				useFormatting = Boolean.valueOf(useFormattingText).booleanValue();
			}

			if (useFormatting)
			{
				// System.out.println("CONFIG: FORMATTING MAP CONFIG
				// properties ");
				// format map (note this can be an expensive operation)

				Text.formatMap(properties);
				// System.out.println("CONFIG: FORMATTED MAP CONFIG
				// properties ");
			}

			propName = Config.class.getName() + ".setSystemProperties";
			setSystemProperties = Boolean.valueOf(properties.getProperty(propName, "false")).booleanValue();

			// Set system properties with values from configuration
			if (setSystemProperties)
			{
				Set<Object> keySet = properties.keySet();
				String key;
				String sysProp;
				for (Iterator<Object> i = keySet.iterator(); i.hasNext();)
				{
					key = (String) i.next();
					sysProp = System.getProperty(key);

					if (sysProp != null && sysProp.length() > 0)
						continue; // do not override values

					// set system property
					System.setProperty(key, properties.getProperty(key));
				}
			}
			
			
			
		}
		catch (ConfigException e)
		{
			throw e;
		}
		catch (FileNotFoundException e)
		{
			throw new ConfigException(e.getMessage(), e);
		}
		catch (Exception e)
		{
			throw new ConfigException(e.getMessage(), e);
		}
		
		try
		{
			this.registry.notify(this.getClass().getName(), this);
		}
		catch(Exception e)
		{
			Debugger.printWarn(e);
		}
	}
728214
@Override
    public void loadFromProperties(Properties props) {
        String strValue = props.getProperty(container.getSimpleName() + "." + name);
        if (strValue == null)
            return;

        try {
            double doubleValue = Double.parseDouble(strValue);
            set(doubleValue);
        } catch (NumberFormatException nfe) {
        }
    }
786558
public static Properties loadProperties(String filename) throws ConfigurableException {
        log.info("Loading properties from " + filename);
        Properties properties = new Properties();
        FileInputStream input = null;
        try {
            input = new FileInputStream(filename);
            properties.load(input);
        } catch (IOException e) {
            final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage();
            log.error(errMessage, e);
            throw new ConfigurableException(errMessage, e);
        } finally {
            if (null != input) {
                try {
                    input.close();
                } catch (IOException e) {
                    final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage();
                    log.error(errMessage, e);
                }
            }
        }

        return properties;
    }
1171296
public final LinkedProperties
    loadPropertiesXml(final String pFileName)
        throws Exception {
    LinkedProperties props = null;
    URL urlSettingXml = UtlProperties.class
      .getResource(pFileName);
    if (urlSettingXml != null) {
      props = new LinkedProperties();
      InputStream inputStream = null;
      try {
        inputStream = UtlProperties.class.getResourceAsStream(pFileName);
        props.loadFromXML(inputStream);
      } finally {
        if (inputStream != null) {
          inputStream.close();
        }
      }
    }
    return props;
  }
837806
public static Properties loadProperties(String propertyFilePath){
		Properties prop = new Properties();
		InputStream is = null;
		ClassLoader cl = Thread.currentThread().getContextClassLoader();
		try {
			is = cl.getResourceAsStream(propertyFilePath);
			Assert.notNull(is, "Failed to obtain InputStream for " + propertyFilePath);
			prop.load(is);
			resolveSystemPropertyPlaceholders(prop);
		} 
		catch (Exception e) {
			throw new IllegalStateException("Failed to load configuration properties: " + propertyFilePath, e);
		} 
		finally {
			try {
				is.close();
			} catch (Exception e2) {
				// ignore
			}
		}
		return prop;
	}
837462
private final Properties loadPropertiesFile(WsResource res) throws IOException {

        Properties props = new Properties();
        InputStream is = res.get();
        try {
            props.load(is);
        } catch (IOException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(this, tc, "Error loading properties; " + e);
            }
            throw e;
        } finally {
            if (is != null)
                try {
                    is.close();
                } catch (IOException e) {
                }
        }
        return props;
    }
185111
public void load(Resource urlResource) {
		this.propertiesFileUrl = urlResource.getUrl();
		if (null == this.propertiesFileUrl) {
			throw new SettingRuntimeException("Can not find properties file: [{}]", urlResource);
		}
		log.debug("Load properties [{}]", propertiesFileUrl.getPath());
		try (final BufferedReader reader = urlResource.getReader(charset)) {
			super.load(reader);
		} catch (Exception e) {
			log.error(e, "Load properties error!");
		}
	}
1104125
private void loadBuildPropertyFile(Project project, TestContext context) {
        if (StringUtils.hasText(propertyFilePath)) {
            String propertyFileResource = context.replaceDynamicContentInString(propertyFilePath);
            log.info("Reading build property file: " + propertyFileResource);
            Properties fileProperties;
            try {
                fileProperties = PropertiesLoaderUtils.loadProperties(new PathMatchingResourcePatternResolver().getResource(propertyFileResource));
                
                for (Entry<Object, Object> entry : fileProperties.entrySet()) {
                    String propertyValue = entry.getValue() != null ? context.replaceDynamicContentInString(entry.getValue().toString()) : "";

                    if (log.isDebugEnabled()) {
                        log.debug("Set build property from file resource: " + entry.getKey() + "=" + propertyValue);
                    }
                    project.setProperty(entry.getKey().toString(), propertyValue);
                }
            } catch (IOException e) {
                throw new CitrusRuntimeException("Failed to read build property file", e);
            }
        }
    }
754368
protected void loadCacheMapping() {
		File f = new File(getCacheFilePath());
		if (f.exists()) {
			try(InputStream is = new FileInputStream(f); BufferedReader rd = new BufferedReader(new FileReader(f))) {
				cacheProperties.load(is);
				for (Enumeration<?> properyNames = cacheProperties.propertyNames(); properyNames.hasMoreElements();) {
					String propName = (String) properyNames.nextElement();
					if (propName.startsWith(JAWR_MAPPING_PREFIX)) {

						String value = cacheProperties.getProperty(propName);

						String resourceMapping = propName.substring(JAWR_MAPPING_PREFIX.length());
						String[] mappings = value.split(SEMICOLON);
						List<FilePathMapping> fMappings = new CopyOnWriteArrayList<>();

						// TODO check the use of mappingModified
						boolean mappingModified = true;
						for (String fmapping : mappings) {
							String[] mapping = fmapping.split(MAPPING_TIMESTAMP_SEPARATOR);
							long lastModified = Long.parseLong(mapping[1]);
							String filePath = mapping[0];
							if (rsHandler.getLastModified(filePath) != lastModified) {
								mappingModified = false;
								break;
							}
							FilePathMapping fmap = new FilePathMapping(filePath, lastModified);
							fMappings.add(fmap);
						}

						if (mappingModified) {
							linkedResourceMap.put(resourceMapping, fMappings);
						}
					}
				}

			} catch (IOException e) {
				throw new BundlingProcessException("Unable to initialize " + getName() + " Generator cache", e);
			}
		}
	}
413207
static void loadHadoopClustersProps(String filename) {
    // read the property file
    // populate the map
    Properties prop = new Properties();
    if (StringUtils.isBlank(filename)) {
      filename = Constants.HRAVEN_CLUSTER_PROPERTIES_FILENAME;
    }
    try {
      //TODO : property file to be moved out from resources into config dir
      InputStream inp = Cluster.class.getResourceAsStream("/" + filename);
      if (inp == null) {
        LOG.error(filename
            + " for mapping clusters to cluster identifiers in hRaven does not exist");
        return;
      }
      prop.load(inp);
      Set<String> hostnames = prop.stringPropertyNames();
      for (String h : hostnames) {
        CLUSTERS_BY_HOST.put(h, prop.getProperty(h));
      }
    } catch (IOException e) {
      // An ExceptionInInitializerError will be thrown to indicate that an
      // exception occurred during evaluation of a static initializer or the
      // initializer for a static variable.
      throw new ExceptionInInitializerError(" Could not load properties file " + filename
          + " for mapping clusters to cluster identifiers in hRaven");
    }
  }
551945
private static void loadLocalProps() {
        if (null == localProps) {
            localProps = new Properties();
        }

        try {
            InputStream resourceAsStream;
            final String localPropsEnv = System.getenv("LATKE_LOCAL_PROPS");
            if (StringUtils.isNotBlank(localPropsEnv)) {
                LOGGER.debug("Loading local.properties from env var [$LATKE_LOCAL_PROPS=" + localPropsEnv + "]");
                resourceAsStream = new FileInputStream(localPropsEnv);
            } else {
                LOGGER.debug("Loading local.properties from classpath [/local.properties]");
                resourceAsStream = Latkes.class.getResourceAsStream("/local.properties");
            }

            if (null != resourceAsStream) {
                localProps.load(resourceAsStream);
                LOGGER.debug("Loaded local.properties");
            }
        } catch (final Exception e) {
            LOGGER.log(Level.DEBUG, "Loads local.properties failed, ignored");
        }
    }
353720
public Boolean loadPropertiesFile(String path) throws IOException
    {
        Properties prop = new Properties();
        InputStream input = null;

        try {

            input = new FileInputStream(path);
            prop.load(input);

            for(String key : prop.stringPropertyNames()) {
                String value = prop.getProperty(key);
                configs.put(key, value);
            }

            return true;
        } catch (IOException ex) {
            return false;
        }
    }
1236615
private void initialize(@NotNull final String propertiesFilePath) {
        props = new Properties();
        try (InputStream in = FileUtils.getResourceAsStream(propertiesFilePath)) {
            props.load(in);
        } catch (NullPointerException ex) {
            LOGGER.error("Did not find settings file '{}'.", propertiesFilePath);
            LOGGER.debug("", ex);
        } catch (IOException ex) {
            LOGGER.error("Unable to load settings from '{}'.", propertiesFilePath);
            LOGGER.debug("", ex);
        }
        logProperties("Properties loaded", props);
    }
187400
protected void loadQueryProperties(String propertyFilename) {

        Properties properties = new Properties();

        try {
            properties.load(getClass().getClassLoader().getResourceAsStream(propertyFilename));
            m_queries.putAll(CmsCollectionsGenericWrapper.<String, String> map(properties));
            replaceQuerySearchPatterns();
        } catch (Throwable t) {
            if (LOG.isErrorEnabled()) {
                LOG.error(
                    Messages.get().getBundle().key(Messages.LOG_LOAD_QUERY_PROP_FILE_FAILED_1, propertyFilename),
                    t);
            }

            properties = null;
        }
    }