When we use JDBC or some other way to access external resources, the need to read some additional configuration file
example xml or properties, we have to regulate the location of the files created.
Fill in the file name directly
thus creating a property file jdbc.properties of.
And then take the test can be used to access the Java
@Test
public void test3(){
Properties p=new Properties();
InputStream is=Test1.class.getClassLoader().getResourceAsStream("jdbc.properties");
try {
p.load(is);
System.out.println(p.get("user"));
System.out.println(p.get("pwd"));
} catch (IOException e) {
e.printStackTrace();
}
}
user=zhang
pwd=abc123
operation result