PropertiesUtil 工具类
直接上代码
package com.syjsdz.tacticslib.core.util;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Properties;
/**
* show 配置文件读取工具类
* @author Xushd
* @since 2016年11月29日 下午6:27:23
*
*/
public class PropertiesUtil {
private static Properties properties;
static {
properties = new Properties();
String path = Thread.currentThread().getContextClassLoader().getResource("config.properties").getPath();
try {
BufferedReader bf = new BufferedReader(new FileReader(path));
properties.load(bf);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* show 根据key获取配置文件中对应值
* @author Xushd
* @since 2016年11月29日 下午6:26:42
* @param key
* @return 键值
*/
public static String getProperty(String key) {
return properties.getProperty(key);
}
}