如有一web项目,结构如下
SomeWebProject
--src
--com.wing.util
--CustomSQL
--jdbc.properties
--webContent
Custom要读取src/jdbc.properties配置文件,代码如下:
Properties prop = new Properties();
prop.load(CustomSQL.class.getResourceAsStream("/jdbc.properties"));
记得加‘/’,就是从src根目录下开始读了
此文章由 http://www.ositren.com 收集整理 ,地址为: http://www.ositren.com/htmls/68276.html