Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Edit properties file line by line

 
Ranch Hand
Posts: 57
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Folks,

I have to read/edit a properties file WITH comments and write it back in the same file with the same structure.
The reading of the properties is not the problem, I don’t get it to read the file line by line and replace the selected settings.

For an example:
test.properties

I found at stackoverflow to read properties line by line with comment but didn’t work in my project and the comments will show as ## without any comment text and properties.
The properties will be saved in an Arraylist to compare in another bean with some values and there I want to save the changed properties.

Now what I actually have:
my central language handler, I compare the settings and write it back in the properties file

here is my properties reader


The change works fine but the structured properties file is destroyed (unsorted) and without any comments

Thanks for some help


Cheers Chris
 
Saloon Keeper
Posts: 7108
165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This class may help: https://coderanch.com/wiki/660196/Extended-Properties
 
Chris Ernst
Ranch Hand
Posts: 57
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you I will try it
 
PI day is 3.14 (march 14th) and is also einstein's birthday. And this is merely a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic