Load a properties file from the classpath

@param propsName
path to the configuration file
@return Properties the properties object containing the configuration
data
@throws IOException
if an error occurs while accessing the configuration file
339455
private static Properties load(String configFilePath)
	{
		Properties props = new Properties();
		BufferedInputStream fis = null;
		try {
			File configFile = new File(configFilePath);
	        fis = new BufferedInputStream(new FileInputStream(configFile));
	        props.load(fis);
        }
        catch(IOException e){
        	System.err.println("Could not load configuration file "+configFilePath);
        }
        finally{
			if(fis!=null){
			    try {
					fis.close();
				}
				catch (IOException e) {
		        	System.err.println("Error closing file stream of configuration file "+configFilePath);
				}
			}
        }
        return props;
	}
874942
private void loadProperties(final String filename, final int depth) {
    logger.warning("Loading file '" + filename + "'");
    final Properties properties = new Properties();
    try {
      // Load our properties file.
      for (final InputStream io : getInputStreamsForFile(filename)) {
        properties.load(io);
        logger.info("Property file loaded successfully (" + filename + ")");
        io.close();
      }
    }
    catch (final java.io.FileNotFoundException ex) {
      logger.warning("Property file not found (" + filename + ")");
    }
    catch (final java.io.IOException ex) {
      logger.warning("IOException loading file: " + ex.getMessage());
      logger.log(Logging.Priority.FATAL.getLevel(), "Error occured while loading properties file (" + filename + ")", ex);
    }
    allProperties.putAll(properties);
    final String includeFiles[] = readIncludeFiles(filename, depth);
    for (final String includeFile : includeFiles) {
      loadProperties(includeFile, depth + 1);
    }
  }
804232
protected Properties loadConfig (String configPath)
        throws IOException
    {
        Properties config = new Properties();
        try {
            config.load(new FileInputStream(new File(_rdir, configPath)));
        } catch (Exception e) {
            String errmsg = "Unable to load resource manager config [rdir=" + _rdir +
                ", cpath=" + configPath + "]";
            log.warning(errmsg + ".", e);
            throw new IOException(errmsg);
        }
        return config;
    }
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;
        }
    }
189621
public static Properties getResourceAsProperties(ClassLoader loader, String resource) throws IOException {
        Properties props = new Properties();
        InputStream in = null;
        String propfile = resource;
        in = getResourceAsStream(loader, propfile);
        props.load(in);
        in.close();
        return props;
    }
726989
def loadproperty(propname)
    return loadpropertyfile(propname) if File.file?(propname)
    $:.each do |path|
      if File.file?(file = File.join(path, propname))
        return loadpropertyfile(file)
      end
    end
    nil
  end
1032327
public static Properties load(InputStream input) throws IOException {
		Properties properties = new Properties();
		properties.load(input);
		return properties;
	}
650522
@Override
	protected void loadProperties(final Properties props) throws IOException {
		if (locations != null) {
			for (int i = 0; i < locations.length; i++) {
				final Resource location = locations[i];
				if (logger.isInfoEnabled()) {
					logger.info("Loading properties file from " + location);
				}
				File file = null;
				InputStream is = null;
				try {
					try {
						file = location.getFile();
						is = new BufferedInputStream(new FileInputStream(file));
					} catch (final IOException ie) {// ignore
					} finally {
						if (file == null) {
							is = location.getInputStream();
						}
					}

					if (location.getFilename().toLowerCase().endsWith(Constants.XML_FILE_EXTENSION)) {
						persister.loadFromXml(props, is);
					} else if (location.getFilename().toLowerCase().endsWith(Constants.JSON_FILE_EXTENSION)) {
						if (fileEncoding != null) {
							persister.loadFromJson(props, new InputStreamReader(is, Charset.forName(fileEncoding)));
						} else {
							persister.loadFromJson(props, is);
						}
					} else if (location.getFilename().toLowerCase().endsWith(Constants.YAML_FILE_EXTENSION)) {
						if (fileEncoding != null) {
							persister.loadFromYAML(props, new InputStreamReader(is, Charset.forName(fileEncoding)));
						} else {
							persister.loadFromYAML(props, is);
						}
					} else {
						if (fileEncoding != null) {
							persister.load(props, new InputStreamReader(is, Charset.forName(fileEncoding)));
						} else {
							persister.load(props, is);
						}
					}
				} catch (final IOException ex) {
					if (ignoreResourceNotFound) {
						if (logger.isWarnEnabled()) {
							logger.warn("Could not load properties from " + location + ": " + ex.getMessage());
						}
					} else {
						throw ex;
					}
				} finally {
					if (is != null) {
						is.close();
					}
				}
			}
		}
	}
346074
public static void loadCustomerProperties(Properties props){
        for(Entry<Object, Object> entry : props.entrySet()){
            setProperty((String)entry.getKey(), entry.getValue());
        }
    }
929423
@VisibleForTesting
    Map<String, String> loadBaseProperties() throws IOException {
        final Properties props = new Properties();
        for (final String property: StringUtils.split(configuration.getProperty(GeneralOption.SONAR_PROPERTIES), ',')){
            final File propertyFile = new File(StringUtils.strip(property));
            log.info("Loading {}", propertyFile.getAbsolutePath());
            props.load(new FileInputStream(propertyFile));
        }
        return (Map)props;
    }
274692
public static ParameterTool fromPropertiesFile(InputStream inputStream) throws IOException {
		Properties props = new Properties();
		props.load(inputStream);
		return fromMap((Map) props);
	}
88550
private static void readClasspath(Properties props, String path) {
        if ((path != null) && !path.isEmpty()) {
            InputStream is = null;
            Properties result = new Properties();

            try {
                is = SystemConfiguration.class.getResourceAsStream(path);
                result.load(is);
                props.putAll(result);
            } catch (IOException ex) {
                throw new SystemException(ex);
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (IOException ex) {
                        assert false : "This should never occur.";
                    }
                }
            }
        }
    }
1017358
public static ConfigurationLoader from(final Properties props) throws IOException {
        return new ConfigurationLoader(new Function<String, String>() {
            public String apply(String from) {
                return props.getProperty(from);
            }
        });
    }
389182
public static Properties loadProperties(final String fileString) throws IOException {
        final File file = new File(fileString);
        // first try: regular file
        if (file.exists()) {
            return loadProperties(file);
        }
        // second try: classpath resource
        final InputStream resourceStream = Thread.currentThread().getContextClassLoader()
                .getResourceAsStream(fileString);
        if (resourceStream != null) {
            return loadProperties(resourceStream);
        }
        // third/last try: URL
        try {
            final URL url = new URL(fileString);
            return loadProperties(url.openStream());
        } catch (final MalformedURLException e) {
            // there is no guarantee that fileString is a URL at all
        }
        throw new IllegalArgumentException("Unable to find " + fileString);
    }
308242
public static Properties loadProperties(final File file) {
        checkNotNull("file", file);
        checkValidFile(file);
        final Properties props = new Properties();
        try (final InputStream inStream = new FileInputStream(file)) {
            props.load(inStream);
        } catch (final IOException ex) {
            throw new RuntimeException(ex);
        }
        return props;
    }
877440
private Map<String, Object> loadPropertyFiles() {
        final Map<String, Object> definedProps = new HashMap<>();
        for (int propertyFileIndex = 0; propertyFileIndex < propertyFiles.size(); propertyFileIndex++) {
            final String filename = propertyFiles.elementAt(propertyFileIndex);
            final Properties props = new Properties();
            FileInputStream fis = null;
            try {
                fis = new FileInputStream(filename);
                props.load(fis);
            } catch (final IOException e) {
                System.out.println("Could not load property file " + filename + ": " + e.getMessage());
            } finally {
                FileUtils.close(fis);
            }

            // ensure that -D properties take precedence
            final Enumeration propertyNames = props.propertyNames();
            while (propertyNames.hasMoreElements()) {
                final String name = propertyNames.nextElement().toString();
                if (!definedProps.containsKey(name)) {
                    final Argument arg = getPluginArguments().get("--" + name);
                    final String value = props.getProperty(name);
                    if (arg != null) {
                        definedProps.put(name, arg.getValue(value));
                    } else {
                        definedProps.put(name, value);
                    }
                }
            }
        }
        return definedProps;
    }
248879
@SuppressWarnings("resource")
	public static AsyncWork<Properties, Exception> loadPropertiesFile(
		IO.Readable.Buffered input, Charset charset, byte priority, IO.OperationType closeInputAtEnd, Listener<Properties> onDone
	) {
		BufferedReadableCharacterStream cs = new BufferedReadableCharacterStream(input, charset, 512, 32);
		return loadPropertiesFile(cs, priority, closeInputAtEnd, onDone);
	}