1. java.util包
      2. 继承 HashTable(HashMap的早期版本) 所以使用方式像是map集合
      3. 虽然从继承关系来讲Proterties使用方式像是map集合 但从读取的东西来说 它读取的是文件中的信息 所以它更像是一个流(高级流)
      4. 构造方法 一个字节型输入流 一个字符型输入流
      Properties pro = new Properties();
      pro.load(new FileInputStream(“src//Test.properties”)); //字节型
      pro.load(new FileReader(“src//Test.properties”)); //字符型
      更常用的方法(通常文件的路径是未知的 所以可以这样写)
      InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(“Test.properties”);
      properties.load(is);
      5. 读取的文件后缀名 需是 .propertied 形式 文件中的内容 以key=value形式存在 格式不能改 但是=可以改 可以用 : 或者 空格
      1. public static void main(String[] args) {
      2. try {
      3. Properties pro = new Properties();
      4. //构造方法有两个 一个字节型 一个字符型
      5. //字节型
      6. // pro.load(new FileInputStream("src//Test.properties"));
      7. //字符型
      8. pro.load(new FileReader("src//Test.properties"));
      9. //读取的文件后缀名 需是 .propertied 形式
      10. //文件中的内容 以key=value形式存在的 格式不能改 但是=可以改 可以用 : 或者 空格
      11. //获取key1键对应的value值
      12. String value = pro.getProperty("key1");
      13. //获取全部的键 用于遍历 类似于Set = map.keySet();
      14. Enumeration en = pro.propertyNames();
      15. // Enumeration对象的用法类似于迭代器 en.hasMoreElements(); en.nextElement();
      16. // Iterator it.hasNext(); it.next();
      17. while(en.hasMoreElements()){
      18. //这里需要造型 之前的Iterator是需要泛型 但是这里泛型会报错
      19. String key = (String)en.nextElement();
      20. String value1 = pro.getProperty(key);
      21. System.out.println(value1);
      22. }
      23. } catch (IOException e) {
      24. e.printStackTrace();
      25. }
      26. }