Mick.987

相信开源,才是未来的春天!

 

得到属性文件信息

/**
     * 得到属性文件信息
     * 
     * @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");

宝贝网址:

posted on 2014-06-06 15:39  张朋飞  阅读(133)  评论(0编辑  收藏  举报

导航