文件结构如下:
it1995.properties
it1995.jdbc.url=jdbc:oracle:thin:@//192.168.1.102:1521/orcl
it1995.jdbc.userName=C##DKY
it1995.jdbc.password=C##DKY
it1995.jdbc.className=oracle.jdbc.OracleDriver
it1995.jdbc.poolSize=10
it1995.jdbc.heartTime=30
it1995.jdbc.heartSql=select * from v$version
关键代码如下:
public String getFile(){
String ret = "";
Properties properties = new Properties();
InputStream in = this.getClass().getClassLoader().getResourceAsStream("it1995.properties");
try {
properties.load(in);
} catch (IOException e) {
e.printStackTrace();
}
String str = properties.getProperty("name");
System.out.println(properties);
return ret;
}
源码打包下载地址: