Java Properties Load from File loadConfiguration()

Here you can find the source of loadConfiguration()

Description

load Configuration

License

Open Source License

Declaration

public static void loadConfiguration() throws IOException 

Method Source Code

//package com.java2s;
/*//from   w  w w . j a va 2s. c  o m
 *  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  WSO2 Inc. licenses this file to you 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
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

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

public class Main {
    public static final String PROPERTIES_FILE_NAME = "client.properties";
    public static final String PROPERTY_NAME_USER_ENDPOINT_URL = "user.endpoint";
    public static final String PROPERTY_NAME_GROUP_ENDPOINT_URL = "group.endpoint";
    public static final String PROPERTY_NAME_USER_NAME = "provisioning.user.name";
    public static final String PROPERTY_NAME_PASSWORD = "provisioning.password";
    public static final String PROPERTY_NAME_ENABLE_OAUTH = "enable.oauth";
    public static final String PROPERTY_NAME_ACCESS_TOKEN = "oauth.access.token";
    public static String userEndpointURL = null;
    public static String groupEndpointURL = null;
    public static String userName = null;
    public static String password = null;
    public static boolean enableOAuth = false;
    public static String oauthAccessToken = null;

    public static void loadConfiguration() throws IOException {
        Properties properties = new Properties();
        FileInputStream freader = new FileInputStream(PROPERTIES_FILE_NAME);
        properties.load(freader);

        userEndpointURL = properties
                .getProperty(PROPERTY_NAME_USER_ENDPOINT_URL);
        groupEndpointURL = properties
                .getProperty(PROPERTY_NAME_GROUP_ENDPOINT_URL);
        userName = properties.getProperty(PROPERTY_NAME_USER_NAME);
        password = properties.getProperty(PROPERTY_NAME_PASSWORD);
        String isOAuth = properties.getProperty(PROPERTY_NAME_ENABLE_OAUTH);
        enableOAuth = Boolean.parseBoolean(isOAuth);
        oauthAccessToken = properties
                .getProperty(PROPERTY_NAME_ACCESS_TOKEN);
    }
}

Related

  1. loadCfg(String url)
  2. loadConfig(File settingsFile)
  3. loadConfigByPath(String path)
  4. loadConfigProperties()
  5. loadConfigProperties()
  6. loadConfiguration(String file)
  7. loadConfiguration(String filePath)
  8. loadCredentials(File credentials, String credentialsAppend)
  9. loadCryptoProperties()