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.
Joined: Jul 11, 2008
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: