读取配置文件:
/**
* 通过文件路径载入数据
*
* @param fileName 文件路径
* @return {@link Properties}
*/
public static Properties getPropertiesByFileName(String fileName) {
Properties prop = new Properties();
try (BufferedReader bf = new BufferedReader(new InputStreamReader(PropertiesUtil.class.getClassLoader().getResourceAsStream(fileName), "UTF-8"))) {
if (bf == null) {
return prop;
}
prop.load(bf);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
return prop;
}