Java Properties Load from File loadConfigByPath(String path)

Here you can find the source of loadConfigByPath(String path)

Description

load Config By Path

License

Open Source License

Declaration

public static Properties loadConfigByPath(String path) throws Exception 

Method Source Code

//package com.java2s;
/*/*from   ww  w.j  a  v  a 2  s .  c o  m*/
 * Copyright (c) 2008  Los Alamos National Security, LLC.
 *
 * Los Alamos National Laboratory
 * Research Library
 * Digital Library Research & Prototyping Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 * 
 */

import java.io.FileInputStream;

import java.io.IOException;
import java.io.InputStream;

import java.util.Properties;

public class Main {
    public static Properties loadConfigByPath(String path) throws Exception {
        FileInputStream fi = new FileInputStream(path);
        return loadProperty(fi);
    }

    public static Properties loadProperty(InputStream in) throws IOException {
        Properties prop;
        try {
            prop = new java.util.Properties();
            prop.load(in);
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (Exception ex) {
                }
            }
        }
        return prop;
    }
}

Related

  1. loadAccessTokenProperties( InputStream inputStream)
  2. loadApiProperties(InputStream inputStream)
  3. loadBuildProperties(File projectRootDir)
  4. loadCfg(String url)
  5. loadConfig(File settingsFile)
  6. loadConfigProperties()
  7. loadConfigProperties()
  8. loadConfiguration()
  9. loadConfiguration(String file)