1 public static void fun1(){ 2 Properties v = new Properties(); 3 v.setProperty("a","1"); 4 v.setProperty("a1","11"); 5 v.setProperty("a2","111"); 6 System.out.println(v); 7 // 获取键值 8 String s = v.getProperty("a"); 9 // 根据 键 获取 值 10 System.out.println(s); 11 //将集合中的键 存储到Set集合 12 Set<String> set = v.stringPropertyNames(); 13 for(String k:set){ 14 //System.out.println(k); 15 String value = v.getProperty(k); 16 System.out.println(k+":"+value); 17 } 18 }