得到src目录下的properties文件属性
生活随笔
收集整理的這篇文章主要介紹了
得到src目录下的properties文件属性
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
/**************************************************************************** 得到指定properties文件中的對應屬性的值* * @param propertiesName* 文件名稱* @param paramname* 屬性名稱* @return paramvalue 返回對應屬性值* **************************************************************************/public String getPropert(String propertiesName, String paramname) {InputStream in = this.getClass().getClassLoader().getResourceAsStream(propertiesName);Properties prop = new Properties();String paramvalue = null;try {prop.load(in);paramvalue = prop.getProperty(paramname).trim();} catch (IOException e) {e.printStackTrace();} finally {try {in.close();} catch (IOException e) {e.printStackTrace();}}return paramvalue;} this.getClass().getClassLoader().getResourceAsStream(""); 是得到src根目錄的路徑 發布后默認為WEB-INF\classes目錄轉載于:https://www.cnblogs.com/mingf123/p/3844954.html
總結
以上是生活随笔為你收集整理的得到src目录下的properties文件属性的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 数学图形(1.42)拱形曲线
- 下一篇: MFC通过ODBC连接mysql(使用V