?
哎 . ?年纪大了就越来越懒了... ?不废话,直接代码了.
?
?
public class PropertiesTools { /** *读取资源文件(在容器中) * @param fileName 这个是从根目录开始 eg:conf/area.properties * @return */ public static String getProperties(String key,String fileName){ Properties rc = null; try { rc = new Properties(); ClassLoader cl = new PropertiesTools().getClass().getClassLoader(); InputStream is = cl.getResourceAsStream(fileName); rc.load(is); } catch (IOException e) { e.printStackTrace(); } return rc.getProperty(key); } }