public void test(){
InputStream ips=this.getClass().getResourceAsStream("/oracle.properties");
Properties properties=new Properties();
try {
properties.load(ips);
System.out.println(properties.getProperty("jdbc.url"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
InputStream ips=this.getClass().getResourceAsStream("/oracle.properties");
Properties properties=new Properties();
try {
properties.load(ips);
System.out.println(properties.getProperty("jdbc.url"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
本文展示了一个使用Java从资源目录加载并读取oracle.properties文件中jdbc.url属性值的示例代码。通过此示例,读者可以了解如何利用Java的InputStream和Properties类来实现这一功能。
1233

被折叠的 条评论
为什么被折叠?



