项目中读取资源文件

来源:互联网 发布:ubuntu ssh开机自启动 编辑:程序博客网 时间:2024/06/11 15:44
Properties props=new Properties();
props.load(this.getClass().getResourceAsStream("newProduct.properties")); //是读取当前类所在位置一起的db.properties文件
//props.load(new FileInputStream("db.properties")); 是读取当前目录的db.properties文件
 /*  ResourceBundle res = ResourceBundle.getBundle("yy.properties");
     String name = res.getString("yyyy");//yy.properties应放在/WEB-INF/classes目录
 */
String date = props.getProperty("lookDate");   //取值
props.put("lookDate", new Date()); //存值
0 0
原创粉丝点击