必背代码-读取javaWeb中.properties文件

	//读取文件,原文件路径:/src/db.properties
			InputStream in = this.getServletContext().getResourceAsStream("/WEB-INF/classes/db.properties");
			
			//读取peoperties文件
			Properties props = new Properties();
			props.load(in);
			
			String url = props.getProperty("url");
			String username = props.getProperty("username");
			String password = props.getProperty("password");


你可能感兴趣的:(必背代码-读取javaWeb中.properties文件)