现在的位置: 首页 > 综合 > 正文

读取配置文件中的信息

2013年06月07日 ⁄ 综合 ⁄ 共 357字 ⁄ 字号 评论关闭

    在我们的开发过程中,很多时候我们需要从配置文件中读取信息,再到java程序中做处理,如:

DBconfig.properites中配置了:

driver=com.mysql.jdbc.driver

url=jdbc.mysql:localhost:3306/db

username=root

passwd=1

 

在java中可以这样调用:

Properties prop=new Properties();

try{

prop.load(this.getClass().getClassLoad().getResourceAsStream("DBconfig.properites");

drvier=prop.getProperties("driver");

prop.getPropertiess("url");

}

catch{

}

抱歉!评论已关闭.