Utility method to load properties from file.

@return Properties the loaded properties
@throws BuildException
979483
private function loadProperties()
    {
        try {
            $properties = new Properties();
            $properties->load($this->file);
        } catch (IOException $ioe) {
            throw new BuildException($ioe);
        }
        return $properties;
    }
263558
private static Properties getPropertiesFile() {
        try {

            // We use the class loader to load the properties file.
            // This compatible with unix and windows.
            final InputStream stream = TangoFactory.class.getClassLoader().getResourceAsStream(
                    FACTORY_PROPERTIES);
            final Properties properties = new Properties();

            // We read the data in the properties file.
            if (stream != null) {
                // We need to use a Buffered Input Stream to load the datas
                final BufferedInputStream bufStream = new BufferedInputStream(stream);
                properties.clear();
                properties.load(bufStream);
            }
            return properties;
        } catch (final Exception e) {
            e.printStackTrace();
            return null;
        }
    }
134436
public static Properties load(InputStream inputStream) {
        Properties configs = new Properties();
        try {
            configs.load(new UnicodeInputStream(inputStream).skipBOM());
        } catch (IOException e) {
            LOGGER.warn("Load properties from inputStream error!", e);
        }
        return configs;
    }
182971
protected static Properties loadConfig(File file) {
    InputStream is = null;
    try {
      is = new FileInputStream(file);
      return loadConfig(file.getAbsolutePath(), is);     
    } catch (Exception ex) {
      throw new IllegalArgumentException("Failed to load configuration from [" + file.getAbsolutePath() + "]");
    }finally {
      if(is!=null) try { is.close(); } catch (Exception ex) { /* No Op */ }
    }
  }
1203441
public static Properties loadFile(File file) throws IOException {
		InputStream input = new FileInputStream(file);
		Properties prop = null;
		try {
			prop = load(input);
		} finally {
			IOUtils.close(input);
		}
		return prop;
	}
79089
public static Properties loadProperties(File file) throws IOException {
        FileInputStream finp = new FileInputStream(file);
        try {
            Properties p = new Properties();
            p.load(finp);
            return p;
        } finally {
            ArchiveUtils.closeQuietly(finp);
        }
    }
977942
@SuppressWarnings("nls")
    private void load() {
        URL url = Version.class.getResource("version.properties");
        if (url == null) {
            this.versionString = "Unknown";
            this.versionDate = new Date().toString();
        } else {
            allProperties = new Properties();
            try(InputStream is = url.openStream()){
                allProperties.load(is);
                this.versionString = allProperties.getProperty("version", "Unknown");
                this.versionDate = allProperties.getProperty("date", new Date().toString());
                this.vcsDescribe = allProperties.getProperty("git.commit.id.describe", "Non-Git Build");
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
706140
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;
    }
608780
public function main()
    {
        if ($this->file === null) {
            throw new BuildException("You must specify file to load properties from", $this->getLocation());
        }

        $props = $this->loadFile($this->file);
        $this->addProperties($props);
    }
1374880
public static Properties readProperties(File _file) {
        if (_file.exists()) {
            try {
                return readProperties(new FileInputStream(_file));
            } catch (FileNotFoundException _ex) {
                LOGGER.info("Could not load properties file: " + _file, _ex);
            }
        }
        return null;
    }
462247
@Override
	public synchronized Map<Object, Object> getProperties()
	{

		if (properties == null || this.isAlwaysReload())
		{
			loadProperties();
		}

		// return copy

		return new HashMap<Object, Object>(properties);
	}
1007471
@SuppressWarnings("resource")
	public static AsyncWork<Properties, Exception> loadPropertiesFile(
		File file, Charset charset, byte priority, boolean closeSynchronous, Listener<Properties> onDone
	) {
		FileIO.ReadOnly input = new FileIO.ReadOnly(file, priority);
		return loadPropertiesFile(
			input, charset, priority,
			closeSynchronous ? IO.OperationType.SYNCHRONOUS : IO.OperationType.ASYNCHRONOUS,
			onDone);
	}
170318
public Properties build() {
        Properties buildProperties = new Properties();
        merge(_defaultProperties, buildProperties);
        merge(_modelProperties, buildProperties);
        merge(_overrideProperties, buildProperties);
        return buildProperties;
    }
219083
protected Properties loadProperties(Resource resource, String filename) throws IOException {
		InputStream is = resource.getInputStream();
		Properties props = new Properties();
		try {
			if (resource.getFilename().endsWith(XML_SUFFIX)) {
				if (logger.isDebugEnabled()) {
					logger.debug("Loading properties [" + resource.getFilename() + "]");
				}
				this.propertiesPersister.loadFromXml(props, is);
			}
			else {
				String encoding = null;
				if (this.fileEncodings != null) {
					encoding = this.fileEncodings.getProperty(filename);
				}
				if (encoding == null) {
					encoding = this.defaultEncoding;
				}
				if (encoding != null) {
					if (logger.isDebugEnabled()) {
						logger.debug("Loading properties [" + resource.getFilename() + "] with encoding '" + encoding + "'");
					}
					this.propertiesPersister.load(props, new InputStreamReader(is, encoding));
				}
				else {
					if (logger.isDebugEnabled()) {
						logger.debug("Loading properties [" + resource.getFilename() + "]");
					}
					this.propertiesPersister.load(props, is);
				}
			}
			return props;
		}
		finally {
			is.close();
		}
	}
925011
public static Properties getPropertiesFromClasspath(String fileName)
      throws PropertiesFileNotFoundException {

    Properties props = new Properties();
    try {
      InputStream is = ClassLoader.getSystemResourceAsStream(fileName);
      if (is == null) { // try this instead
        is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
        logger.debug("loaded properties file with Thread.currentThread()");
      }
      props.load(is);
    } catch (Exception e) {
      throw new PropertiesFileNotFoundException(
          "ERROR LOADING PROPERTIES FROM CLASSPATH >" + fileName + "< !!!", e);
    }
    return props;
  }
375521
public static Properties load(File file) throws IOException {
        if (file.isFile()) {
            return load(file.toURI().toURL());
        }
        return new Properties();
    }
1190310
public function enumerateGets()
    {
        foreach ($this->gets as $get) {
            $outProperty = $get->getOutputProperty();
            $property = $get->getProperty();
            $section = $get->getSection();
            $value = '';

            if ($property === null) {
                throw new BuildException("property must be set");
            }
            if ($outProperty === null) {
                throw new BuildException("outputproperty must be set");
            }
            if ($section === null) {
                throw new BuildException("section must be set");
            }
            try {
                $value = $this->ini->get($section, $property);
            } catch (RuntimeException $ex) {
                $this->logDebugOrMore(
                    sprintf(
                        '%s: section = %s; key = %s',
                        $ex->getMessage(),
                        $section,
                        $property
                    )
                );
            } finally {
                if ($value === '') {
                    $value = $get->getDefault();
                }
            }

            $project = $this->getProject();
            $project->setProperty($outProperty, $value);
            $this->logDebugOrMore(
                sprintf(
                    'Set property %s to value \'%s\' read from key %s in section %s',
                    $outProperty,
                    $value,
                    $property,
                    $section
                )
            );
        }
    }