*
The moose likes Java in General and the fly likes setting values in properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "setting values in properties file" Watch "setting values in properties file" New topic
Author

setting values in properties file

imran quazi
Greenhorn

Joined: Dec 01, 2006
Posts: 18
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

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
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 ]

Rahul Bhattacharjee
LinkedIn - Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting values in properties file
 
Similar Threads
Beginner Java Question
Sorting arrays
Help wit h code
RMI 001
Correlation in SQL to distinguish tables