Java Properties Load from File loadProperties(String fileName)

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

Description

load Properties

License

Apache License

Declaration

public static Properties loadProperties(String fileName) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Main {
    public static Properties loadProperties(String fileName) {
        Properties properties = null;
        InputStream stream = null;

        try {/*ww  w.j  av a  2 s .c  o  m*/
            stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
            if (null == stream) {
                throw new FileNotFoundException(fileName + "is Not Found");
            }
            properties = new Properties();
            properties.load(stream);
        } catch (IOException e) {
            if (null != stream) {
                try {
                    stream.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }
        return properties;
    }
}

Related

  1. loadProperties(Properties properties, File propertyFile)
  2. loadProperties(String configFilePath)
  3. loadProperties(String configurationFileProperty, String configurationFileDefault)
  4. loadProperties(String configurationPath)
  5. loadProperties(String file)
  6. loadProperties(String filename)
  7. loadProperties(String filename)
  8. loadProperties(String fileName)
  9. loadProperties(String fileName, boolean systemOverride)