How to use Java property files?

后端 未结 17 1503
时光取名叫无心
时光取名叫无心 2020-11-22 11:13

I have a list of key/value pairs of configuration values I want to store as Java property files, and later load and iterate through.

Questions:

  • Do I ne
17条回答
  •  礼貌的吻别
    2020-11-22 11:42

    Example:

    Properties pro = new Properties();
    FileInputStream in = new FileInputStream("D:/prop/prop.properties");
    pro.load(in);
    String temp1[];
    String temp2[];
    // getting values from property file
    String username = pro.getProperty("usernamev3");//key value in prop file 
    String password = pro.getProperty("passwordv3");//eg. username="zub"
    String delimiter = ",";                         //password="abc"
    temp1=username.split(delimiter);
    temp2=password.split(delimiter);
    

提交回复
热议问题