Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Properties Files - Maintaining their Order

 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am writing to a properties file that is in sections. i.e.

[SectionName]
key.keyidentifier=value

[SecondSectionName]
another.key=value

My question is, when changing a property and writing it back to the file I can't seem to maintain this structure. The keys with values go to the top of the file and the sections go to the middle. How do I write to the file and keep the file layout the same?

Thanks,
Rachel
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
unlike Windows ini-files, properties files don't support sectioning.

You're better off using some other format, maybe XML.
Or name your properties different, like section.property=value
 
reply
    Bookmark Topic Watch Topic
  • New Topic