/** * */ package com.bonus.core; import java.io.InputStream; import java.util.Properties; /** * * @table * @Description: * @author **fly** * @date 2019年12月11日 下午9:16:49 * @version V1.0 */ public class PropertiesUtils { /** * 根据key读取value * @param filePath * @param key * @return */ public static String readValue(String filePath, String key) { Properties props = new Properties(); try { // InputStream in = new BufferedInputStream(new FileInputStream(filePath)); InputStream in = PropertiesUtils.class.getClassLoader().getResourceAsStream(filePath); props.load(in); String value = props.getProperty(key); // System.out.println(key + value); return value; } catch (Exception e) { e.printStackTrace(); return null; } } }