Java Properties Load from File loadPropertiesFile(String filePath)

Here you can find the source of loadPropertiesFile(String filePath)

Description

load Properties File

License

Apache License

Declaration

public static Properties loadPropertiesFile(String filePath) 

Method Source Code

//package com.java2s;
/*********************************************************************
 * ?????????????????/*from  w  w w .j  a  va2 s  .c  o  m*/
 *
 * ? Apache License, Version 2.0 ??????????????????
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 ********************************************************************/

import java.io.FileInputStream;

import java.io.InputStream;

import java.util.Properties;

public class Main {

    public static Properties loadPropertiesFile(String filePath) {
        Properties properties = new Properties();
        InputStream is = null;

        try {
            try {
                is = new FileInputStream(filePath);
                properties.load(is);
            } finally {
                if (is != null) {
                    is.close();
                    is = null;
                }
            }
        } catch (Exception e) {
            properties = null;
        }

        return properties;
    }

    public static Properties loadPropertiesFile(InputStream is) {
        Properties properties = new Properties();

        try {
            try {
                properties.load(is);
            } finally {
                if (is != null) {
                    is.close();
                    is = null;
                }
            }
        } catch (Exception e) {
            properties = null;
        }

        return properties;
    }
}

Related

  1. loadPropertiesFile(File file, boolean critical)
  2. loadPropertiesFile(final File file)
  3. loadPropertiesFile(String fileName)
  4. loadPropertiesFile(String fileName)
  5. loadPropertiesFile(String filePath)
  6. loadPropertiesFile(String path)
  7. loadPropertiesFile(String propertiesFileName)
  8. loadPropertiesFile(String propFile)
  9. loadPropertiesFile(String propFilePath)