Java Properties Load from File loadProperties(String propertiesFile)

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

Description

load Properties

License

Apache License

Declaration

private static Properties loadProperties(String propertiesFile) throws IOException 

Method Source Code


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

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import java.util.Properties;

public class Main {
    private static Properties loadProperties(String propertiesFile) throws IOException {
        if (propertiesFile != null) {
            File file = new File(propertiesFile);
            if (file.exists()) {
                Properties properties = new Properties();
                FileInputStream inputStream = new FileInputStream(propertiesFile);
                try {
                    properties.load(inputStream);
                } finally {
                    inputStream.close();
                }//  ww w. java 2 s. c o  m
                return properties;
            } else {
                throw new FileNotFoundException(propertiesFile);
            }
        } else {
            return null;
        }
    }
}

Related

  1. loadProperties(String filePath)
  2. loadProperties(String path)
  3. loadProperties(String path, Class caller)
  4. loadProperties(String path, Properties defaults)
  5. loadProperties(String propertiesFile)
  6. loadProperties(String propertyFile)
  7. loadProperties(String propertyPath)
  8. loadProperties(String propsFile)
  9. loadProperties(String sFile)