讀配置文件property文件

import java.io.IOException;import java.util.Properties;import org.springframework.core.io.support.PropertiesLoaderUtils;/** * Description: 讀取配置文件http地址配置<br> */public class ConfigFileUtils {    /**     * 讀取authconfig.properties     *      * @param nodeName     * @return     */    public static String getAuthconfig(String nodeName) {        String configName = "application.properties";        String result = pubReadConfig(configName, nodeName);        if (result == null) {            result = pubReadConfig("prop/" + configName, nodeName);        }        return result;    }    /**     * 通用讀取方法     *      * @param configName     * @param nodeName     * @return     */    public static String pubReadConfig(String configName, String nodeName) {        Properties props = new Properties();        while (true) {            try {                props = PropertiesLoaderUtils.loadAllProperties(configName);                return (String) props.get(nodeName);            } catch (IOException e) {                System.out.println(e.getMessage());            }        }    }}
相關文章
相關標籤/搜索