Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting values in properties file

 
imran quazi
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to know is it possible to set the values in a properties file thru java program?
The scenario is like this: i'm getting 2 or more product id's from xml. Now i've to display a proper message where that 2 product_id will be inserted. The message is already defined in the properties file as a template. Now i've written the properties file like this:

That product1 & product2 value should come from xml.How can i do this?

Another thing is that,i'm using eclipse and its giving error:

Where i've to keep the properties file? i've tried keeping it at the same place where java files are residing, in a different folder outside the package...but its giving the same error...

please help
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Properties class has a store() method to write out to a file. Read your properties file in, manipulate the properties as you need then call store().


Where i've to keep the properties file? i've tried keeping it at the same place where java files are residing, in a different folder outside the package...but its giving the same error...

Basically, in the classpath. It looks like you are using a ResourceBundle; are you loading it via the getBundle() method? The JavaDocs explain the logic behind finding the file.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case your application is not Locale aware then you can just use file inputstream to read the .properties file to a Properties object and the manipulate that.
[ April 23, 2007: Message edited by: Rahul Bhattacharjee ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic