package com.kingdee.eas.custom.beisen.utils;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
/**
* 获取配置文件参数值
* description: BeisenParamByProperties
* date: 2025/7/7 16:03
* author: lhbj
* version: 1.0
*/
public class BeisenParamByPropertiesUtil {
private static Logger logger =Logger.getLogger(BeisenParamByPropertiesUtil.class);
private Properties propt = new Properties();//共用参数
/**
* filePath地址从server开始,例:/server/properties/beisen/beisenConfig.properties
* @param filePath
*/
public BeisenParamByPropertiesUtil(String filePath) throws IOException {
this.initConfig(System.getProperty("EAS_HOME") + filePath);
}
public BeisenParamByPropertiesUtil() throws IOException {
}
public BeisenParamByPropertiesUtil initConfig(String filePath) throws IOException {
try {
if(StringUtils.isBlank(filePath)){
throw new IOException("filePath参数为空");
}
this.propt.load(new FileInputStream(filePath));
return this;
}catch (IOException e){
e.printStackTrace();
logger.error("未找到"+filePath+"配置文件。");
throw e;
}
}
public Map getConfig() {
Map map = Maps.newHashMap();
Set> set = this.propt.entrySet();
for(Map.Entry