properties配置文件

来源:互联网 发布:服务器同步备份软件 编辑:程序博客网 时间:2024/05/22 14:16
/**
 * 
 * @file  PathUtil.java
 * @brief 类简要说明:
 *  
 * 类详细说明:配置文件
 *    @author  zhengkunqi   
* @version  1.0
*    -  下午09:53:15   2017-5-11
 */
public class PathUtil {

private static Properties properties = null;

/**
* 加载类时,先执行静态代码块
*/
          static{
                    try {
                              //加载配置文件
                              InputStream is = PathUtil.class.getResourceAsStream("path.properties");
                              properties = new Properties();
                              properties.load(is);
                    } catch (Exception e) {
                              e.printStackTrace();
                    }
          }

/**

* @brief   getValue 方法简要说明:

* 方法详细说明:根据key值取得对应的value值
 *    @author  zhengkunqi
 * @version  1.0
 *   - 下午09:53:44   2017-5-11
* @par  参数说明
*@param str
*@return
* @par 变更历史: 
*    - 时间  作者   修改说明
*/
public static String getValue(String str) {
          return properties.getProperty(str);
}


0 0