jsp编程中读取数据库属性文件为什么要用Properties prop=new Properties();
InputStream is=this.getClass().getResourceAsStream("/connetion.properties");
而不是FileInputStream fin=new FileInputStream("/connetion.properties");不是读取文件吗
InputStream is=this.getClass().getResourceAsStream("/connetion.properties");
而不是FileInputStream fin=new FileInputStream("/connetion.properties");不是读取文件吗
java会搜索classpath来定位该资源的位置,资源文件甚至可以处于jar包中。这样脱离了和具体操作系统文件的关系,系统更灵活。