tomp110 发表于 2013-2-7 16:15:36

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]
查看完整版本: Properties读取任意目录的配置文件