public class ListTest {
@Test
public void test3() throws IOException{
Properties properties = new Properties();
// 这个方法会自动处理文件, 把文件中的内容全部加载到map集合中
properties.load(new FileInputStream("test.properties"));
// 等价于 get()
String property = properties.getProperty("email");
System.out.println(property);
String property2 = properties.getProperty("username");
System.out.println(property2);
String property3 = properties.getProperty("password");
System.out.println(property3);
properties.setProperty("mobile", "15353353535");
System.out.println("-------------------");
System.out.println(properties);
}
Properties类的应用
最新推荐文章于 2022-12-07 16:27:27 发布