Good day. Actually the question in the title.

Properties p = new Properties(); p.load(inputStream); 

That reached this point. How now to get pairs of key: value, provided that I already have a Map and I need to save it, but the typification cannot be changed?

    2 answers 2

    Properties class is a descendant of Hashtable. Therefore, you can either use it or copy all the values ​​into the new Map.

     Map<Object, Object> map = new HashMap<>(); for(Map.Entry<Object, Object> entry: p.entrySet()) { map.put((String) entry.getKey(), (String) entry.getValue()); } 
    • @Gerltsx I corrected the answer - Mikhail Vaysman
    • Thanks a lot for the tip. - Gerltsx

    using java 8 features:

     Properties p = new Properties(); p.load(inputStream); Map<String, String> map = new HashMap<>(); p.forEach((k, v) -> {map.put((String) k, (String) v);});