java - How to fix weird ordering in setProperty or put for Properties class -


i'm having dilemma on ordering of setproperty or put properties class.

the idea want save sorted properties file. i've got sorting classes ready, when setproperty or put, arrangement becomes weird.

properties tmp = new properties(); tmp.setproperty("a1","b"); tmp.setproperty("a2","b"); tmp.setproperty("a3","b"); tmp.setproperty("a4","b"); tmp.setproperty("a5","b"); 

the output when tmp.list(system.out) becomes:

-- listing properties -- a4=b a3=b a2=b a1=b a5=b 

the same arrangement goes when using put.

i'm not sure why.. need save sorted properties in *.properties file.

any appreciated. thanks!

the properties class extends hashtable , not define guaranteed sort order. best best try treemap instead gives natural sort order of keys. if want save , load though, you'll have roll own logic these operations not come on treemap. let me know if want see code examples these.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -