从配置文件读取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"));
	}
}

猜你喜欢

转载自blog.csdn.net/Sun_of_Rainy/article/details/86148651