properties文件应用
条件:在项目中的src目录下有一个DataBaseConfig.properties文件:
目标:实现读取此properties文件中键所对应的值。
?
实现:
???????
Properties prop = new Properties(); String path = request.getRealPath("WEB-INF/classes/DataBaseConfig.properties");prop.load(new FileInputStream(path)); //--------------------读取properties文件中的DBNAME对应的值------------------------ String DBNAME = prop.getProperty("DBNAME");
?
?