Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ordering keys of property file  RSS feed

 
prasad Venkat
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to store key,values pair into property file in taken order
or how to sort them
thanks in advance
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Properies files don't imply any order - why should they? All they exist to do is store key value pairs

(Also, not an advanced question, moving...)
 
Luciano Mantuaneli
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you really want to do this:
  • Create an java.util.Properties object
  • Load your property file into the Properties object
  • Create an TreeMap object, passing to its constructor your Properties object
  • Use a simple for strategy to output the key-value pairs of the TreeMap objecto into a String object
  • write that String into your file

  • Have Fun!
     
    Consider Paul's rocket mass heater.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!