Java Properties Load loadProperties(String propertyName)

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

Description

Loads a properties file in the startup directory

License

Open Source License

Parameter

Parameter Description
propertyName a parameter

Exception

Parameter Description
Exception an exception

Declaration

public static Properties loadProperties(String propertyName)
        throws Exception 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileInputStream;

import java.util.Properties;

public class Main {
    /**//from   w w  w .  ja va  2s.co m
     * Loads a properties file in the startup directory
     * 
     * @param propertyName
     * @return
     * @throws Exception
     */
    public static Properties loadProperties(String propertyName)
            throws Exception {
        Properties props = new Properties();
        File file = new File(propertyName);
        FileInputStream fis = null;
        if (file.exists()) {
            fis = new FileInputStream(file);
            props.load(fis);
        } else {
            props = null;
        }
        return props;
    }
}

Related

  1. loadProperties(String bucketName, String key)
  2. loadProperties(String conf)
  3. loadProperties(String name, ClassLoader loader)
  4. loadProperties(String properties)
  5. loadProperties(String properties)
  6. loadProperties(String resource)
  7. loadProperties(String resourceName)
  8. loadProperties(String resourceName, ClassLoader classLoader)
  9. loadPropertiesFromResource(ClassLoader clsLoader, String resourcePath)