Populating a HashMap with entries from a properties file

前端 未结 5 1201
南笙
南笙 2020-12-14 08:45

I want to populate a HashMap using the Properties class.
I want to load the entries in the .propeties file and then copy it into

5条回答
  •  悲&欢浪女
    2020-12-14 09:33

    If I understand correctly, each value in the properties is a String which represents an Integer. So the code would look like this:

    for (String key : properties.stringPropertyNames()) {
        String value = properties.getProperty(key);
        mymap.put(key, Integer.valueOf(value));
    }
    

提交回复
热议问题