Java--集合--Properties

  1. 基本介绍
  2.  

    基本使用
    1.  

       

    2. package com.model.map.hashtable.properties;
      
      import java.io.*;
      import java.util.Properties;
      
      /**
       * @Description:测试类
       * @Author: 张紫韩
       * @Crete 2021/6/15 18:47
       */
      public class PropertiesDemo01 {
          public static void main(String[] args) throws IOException {
              /**
               * 1.继承了hashtable
               * 2.键值对不能为null
               * 3.
               * */
              Properties properties=new Properties();
      
              properties.put("a", "a");
              System.out.println(properties.get("a"));
              properties.remove("a");
              properties.put("b", "b");
      
              FileReader fileReader = new FileReader("D:\\qq\\IDEA\\IdeaProjects\\java_mianshi_test\\mianshi_jihe\\src\\main\\java\\com\\model\\map\\hashtable\\properties\\db.properties");
      
              properties.load(new BufferedReader(fileReader));
      
              System.out.println(properties.getProperty("a"));
              System.out.println(properties.getProperty("b"));
          }
      }

       

       

          
posted @ 2021-06-15 19:00  张紫韩  阅读(28)  评论(0编辑  收藏  举报