读取resources目录下的properties文件为properties对象 public static Properties loadProps(String fileName) { Properties props = null; InputStream is = null; try { is = Thread.currentThread().getContextClassLoader().getResourceAsStre
public static Properties loadProps(String fileName) { Properties props = null; InputStream is = null; try { is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); if (is == null) { throw new ClassNotFoundException(fileName + " file is not found"); } props = new Properties(); props.load(is); } catch (ClassNotFoundException | IOException e) { e.printStackTrace(); } finally { if (is != null){ try { is.close(); }catch (IOException e){ LOGGER.error("close input stream failure", e); } } } return props; }