1. 程式人生 > >從配置檔案讀取key對應value的工具類

從配置檔案讀取key對應value的工具類

package com.sunyard.ec.base.util;

import java.util.ResourceBundle;
/**
 * 讀取配置檔案的工具類
 * @author 
 *
 */
public class ConfigUtil {
	
	
	private static final String CONFIG_FILE_NAME = "config";   //config為配置檔案的名字
	private static ResourceBundle resource = null;
	
    static
    {
    	resource = ResourceBundle.getBundle(CONFIG_FILE_NAME);
    }
    
    public static String getValue(String key)
    {
    	return resource.getString(key);
    }

    
    public static void main(String[] args) {
    	System.out.println(ConfigUtil.getValue("template.source.path"));
	}
}