system.properties
user=root
password=root
jdbcUrl=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8;
driverClass=com.mysql.jdbc.Driver
调用方法:
public void getProperties(){
Properties prop = new Properties();
try {
prop.load(new BufferedInputStream(new FileInputStream(this.getClass().getResource("/").getPath().substring(1)+"system.properties")));
System.out.println(prop.getProperty("user"));
System.out.println(prop.getProperty("password"));
System.out.println(prop.getProperty("jdbcUrl"));
System.out.println(prop.getProperty("driverClass"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}