• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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