PropertiesConfiguration--配置文件加载工具类

PropertiesConfiguration是一个配置文件的加载工具类,封装了从配置文件里获取值并转化为基本数据类型的方法。 它来自commons-configuration-1.6.jar。 直接上代码: [java] view plain copy public class Config { private static PropertiesConfiguration config = null; static { try { config = new PropertiesConfiguration( "config.properties"); } catch (ConfigurationException e) { e.printStackTrace(); } } public static String getString(String key) { return config.getString(key); } public static String getString(String key, String def) { return config.getString(key, def); } public static int getInt(String key) { return config.getInt(key); } public static int getInt(String key, int def) { return config.getInt(key, def); } public static long getLong(String key) { return config.getLong(key); } public static long getLong(String key, long def) { return config.getLong(key, def); } public static float getFloat(String key) { return config.getFloat(key); } public static float getFloat(String key, float def) { return config.getFloat(key, def); } public static double getDouble(String key) { return config.getDouble(key); } public static double getDouble(String key, double def) { return config.getDouble(key, def); } public static boolean getBoolean(String key) { return config.getBoolean(key); } public static boolean getBoolean(String key, boolean def) { return config.getBoolean(key, def); } public static String[] getStringArray(String key) { return config.getStringArray(key); } @SuppressWarnings("unchecked") public static List getList(String key) { return config.getList(key); } @SuppressWarnings("unchecked") public static List getList(String key, List def) { return config.getList(key, def); } public static void setProperty(String key, Object value) { config.setProperty(key, value); } } http://blog.csdn.net/majian_1987/article/details/11144335
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值