工具类中 获取配置文件路径问题及方法

 //读取配置文件
        static{
            FileInputStream in = null;
            try {
                Properties properties = new Properties();
                //   phoneUtil.class.getResourceAsStream("/phone.properties") 获取resources下的配置文件 
                properties.load(phoneUtil.class.getResourceAsStream("/phone.properties"));
                ACCESS_KRY_id = properties.getProperty("accessKeyId");
                ACCESS_KEY_SECRET = properties.getProperty("accessKeySecret");
                SIGN_NAME =properties.getProperty("SignName");
                TEMPLATE_CODE = properties.getProperty("TemplateCode");
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (in != null) {
                    try {
                        in.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }

 

posted @ 2018-06-08 09:46  菜鸟~风  阅读(537)  评论(0)    收藏  举报