• 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

setting values in properties file

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Who knew that furniture could be so violent? Put this tiny ad out there to see what happens:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic