package config_demo;
import java.io.InputStream;
import java.util.Properties;
public class UrlDemo {
public void getWebInfUrl() {
//获取配置文件的输入流
InputStream inputStream = getClass().getResourceAsStream("/jdbc.properties");
//实例化配置文件读取类
Properties properties = new Properties();
try{
//加载配置文件
properties.load(inputStream);
//获取配置项的值
String url = properties.getProperty("url");
System.out.println(url);
}catch(Exception e){
//输出异常信息
System.out.println(e.getMessage());
}
}
}