`
菜鸟级JAVA
  • 浏览: 92812 次
  • 性别: Icon_minigender_1
  • 来自: 湖南
社区版块
存档分类
最新评论

读取配置文件工具类

阅读更多
package util;

import java.util.ResourceBundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* 配置文件读写工具类
*
* @author
* @date
* @version 1.0
*/
public class Configuration {

    private static final Logger log = LoggerFactory.getLogger(Configuration.class);

    /**
     * 读取配置文件信息
     *
     * @param name 读取节点名
     * @param fileName 文件名
     * @return 读取的节点值
     */
    public static String readConfigString(String name, String fileName) {
        String result = "";
        try {
            ResourceBundle rb = ResourceBundle.getBundle(fileName);
            result = rb.getString(name);
        } catch (Exception e) {
            log.error("从" + fileName + "读取" + name + "出错:" + e.getMessage());
        }
        return result;
    }
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics