81,091
社区成员
发帖
与我相关
我的任务
分享
public static String getPropertByPath(String filePath ,String fileName ,String propKey) throws IOException{
//构造文件路径
String file = fileName ;
//如果路径为空则默认是src下的文件
if(filePath!=null&&!"".equals(filePath.trim())) file = filePath+"/"+fileName;
//读取文件并构造成文件流
InputStream inStream = PropertiesUtil.class.getClassLoader().getSystemResourceAsStream(file);
//构造属性并装载文件
Properties properties = new Properties();
properties.load(inStream);
return (String)properties.get(propKey);
}