加载配置文件

		//无法获取更新后的数据  -------是因为类装载器只装载一次
		InputStream in = Load.class.getClassLoader().getResourceAsStream("db.properties");
		Properties prop = new Properties();
		prop.load(in);
		prop.get("url");
		
		//可以获取更新后的数据
		String path = Load.class.getClassLoader().getResource("db.properties").getPath();
		FileInputStream file = new FileInputStream(path);
		Properties fileprop = new Properties();
		fileprop.load(file);
		fileprop.get("url");

  

posted @ 2014-03-09 21:08  keia  阅读(125)  评论(0编辑  收藏  举报