先获取一个类加载器然后调用getResourceAsStream方法,指定文件名
在创建一个Properties对象
InputStream is=null;
is=TestConnection(类名).class.getClassLoader().getResourceAsStream("jdbc.properties(文件名)");
Properties properties=new Properties();
properties.load(is);
微信扫一扫
先获取一个类加载器然后调用getResourceAsStream方法,指定文件名
在创建一个Properties对象
InputStream is=null;
is=TestConnection(类名).class.getClassLoader().getResourceAsStream("jdbc.properties(文件名)");
Properties properties=new Properties();
properties.load(is);
相关推荐