Java Properties Load from File loadPropertiesFile(String fileName)

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

Description

Load properties file.

License

Open Source License

Parameter

Parameter Description
fileName the file name

Return

the properties

Declaration

public static Properties loadPropertiesFile(String fileName) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2006-2010 eBay Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *******************************************************************************/

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class Main {
    /**/*from w  w w. j ava  2 s  .  co  m*/
     * Load properties file.
     *
     * @param fileName the file name
     * @return the properties
     */
    public static Properties loadPropertiesFile(String fileName) {
        Properties props = new Properties();
        FileInputStream is = null;
        try {
            is = new FileInputStream(fileName);
            props.load(is);
        } catch (IOException e) {
            return null;
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    // We don't care about the exception
                }
            }
        }
        return props;
    }
}

Related

  1. loadProperties(String propertyPath)
  2. loadProperties(String propsFile)
  3. loadProperties(String sFile)
  4. loadPropertiesFile(File file, boolean critical)
  5. loadPropertiesFile(final File file)
  6. loadPropertiesFile(String fileName)
  7. loadPropertiesFile(String filePath)
  8. loadPropertiesFile(String filePath)
  9. loadPropertiesFile(String path)