在我们的开发过程中,很多时候我们需要从配置文件中读取信息,再到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{
}