zoukankan      html  css  js  c++  java
  • 得到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-INFclasses目录
  • 相关阅读:
    vijos 1894 セチの祈り
    luogu p1378 经验之谈
    審視自己
    高斯消去法的相關拓展
    通用汇点
    重征之战
    有文化的人吟了一句诗
    2016年7月总结
    BZOJ 1026: [SCOI2009]windy数
    BZOJ 1047: [HAOI2007]理想的正方形
  • 原文地址:https://www.cnblogs.com/mingf123/p/3844954.html
Copyright © 2011-2022 走看看