Java Properties Load from File loadCfg(String url)

Here you can find the source of loadCfg(String url)

Description

Description:TODO

License

Apache License

Parameter

Parameter Description
url a parameter

Declaration

private static int loadCfg(String url) 

Method Source Code


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

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

import java.util.Properties;

public class Main {
    private static String DRIVER = null;
    private static String URL = null;
    private static String USERNAME = null;
    private static String PASSWORD = null;
    private static int SUCCESS = 0;
    private static int FAILURE = -1;

    /**//  www .j a v a 2  s. c  o  m
     * <p>Description:TODO</p>
     * @param url
     * @return 
     * @author lijw
     * @since 2013-3-5
     */
    private static int loadCfg(String url) {
        Properties prop = new Properties();
        InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(url);
        try {
            prop.load(in);
            DRIVER = prop.get("jdbc.driverClassName").toString();
            URL = prop.get("jdbc.url").toString();
            USERNAME = prop.get("jdbc.username").toString();
            PASSWORD = prop.get("jdbc.password").toString();
        } catch (IOException e) {
            e.printStackTrace();
            return FAILURE;
        }
        return SUCCESS;
    }
}

Related

  1. load(String resource)
  2. load(String[] paths, String fileName)
  3. loadAccessTokenProperties( InputStream inputStream)
  4. loadApiProperties(InputStream inputStream)
  5. loadBuildProperties(File projectRootDir)
  6. loadConfig(File settingsFile)
  7. loadConfigByPath(String path)
  8. loadConfigProperties()
  9. loadConfigProperties()