TreeMap will sort the properties according to natural ordering of keys (unless you explicitly specify your own Comparator). If you want to have your properties in the order, in which they exist in file, I guess you would have to use Scanner class.
Dariusz Kordonski
Ranch Hand
Joined: Jul 11, 2008
Posts: 49
posted
0
I saw on the other post that you would like to sort properties by values without losing duplicate values. I don't know of any built-in API that could be used to accomplish this directly. You may use a kind of helper class, check out the example code:
TreeMap keeps the entries of the map in the natural order of the keys (or in the order specified by a custom comparator) as already mentioned above.
If you want to keep the entries in the map in the order that they were added to the map, use LinkedHashMap (look it up in the API documentation for more info).