Java Properties Load from File loadProperties(String configFilePath)

Here you can find the source of loadProperties(String configFilePath)

Description

Load the Properties object from the configuration object.

License

Open Source License

Parameter

Parameter Description
configFilePath the file path of the configuration file

Return

the properties loaded

Declaration

private static Properties loadProperties(String configFilePath) 

Method Source Code


//package com.java2s;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Main {
    /**// w w w.jav  a2s .c  o  m
     * Load the Properties object from the configuration object.
     *
     * @param configFilePath the file path of the configuration file
     *
     * @return the properties loaded
     */
    private static Properties loadProperties(String configFilePath) {
        InputStream in = null;

        try {
            Properties prop = new Properties();
            in = new FileInputStream(configFilePath);
            prop.load(in);

            return prop;
        } catch (IOException e) {
            // simply return null, it will never happen
            return null;
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    // ignore the exception
                }
            }
        }
    }
}

Related

  1. loadProperties(Map map, File file, String encoding)
  2. loadProperties(ProcessingEnvironment env, String fileName)
  3. loadProperties(Properties properties, File file)
  4. loadProperties(Properties properties, File propertyFile)
  5. loadProperties(Properties properties, File propertyFile)
  6. loadProperties(String configurationFileProperty, String configurationFileDefault)
  7. loadProperties(String configurationPath)
  8. loadProperties(String file)
  9. loadProperties(String filename)