Properties读取任意目录的配置文件
try{ String url = this.getClass().getResource("").getPath().replaceAll("%20", " "); String path = url.substring(0, url.indexOf("WEB-INF")) + "WEB-INF/config.properties"; Properties config = new Properties(); config.load(new FileInputStream(path)); System.out.println(config.getProperty("dbDriver")); } catch (Exception e){ e.printStackTrace();}转自:http://www.blogjava.net/xiaosilent/archive/2006/12/22/89575.html
页:
[1]