得到属性文件信息

元气小坏坏 提交于 2019-12-28 02:36:33
/**
     * 得到属性文件信息
     * 
     * @param key
     * @return
     */
    public static String getPropertiesByKey(String key) {
        InputStream in=null;
        try {  
  
              in = new ToolsClass().getClass().getResourceAsStream(
                    "/jajnInfo.properties");
            Properties xie = new Properties();
            xie.load(in);// 加载数据流
            return xie.getProperty(key);

        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        finally{
            if(null!=in)
                try {
                    in.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            
        }
    }
    

使用getPropertiesByKey(key关键字); 如: getPropertiesByKey("mail.smtp.host");

宝贝网址:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!