wood burning stoves 2.0*
The moose likes Servlets and the fly likes Writing properties to same properties file . Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Writing properties to same properties file ." Watch "Writing properties to same properties file ." New topic
Author

Writing properties to same properties file .

Zak Nixon
Ranch Hand

Joined: Sep 27, 2003
Posts: 126
All,

I have successfully read my db.properties file
which is located in my WEB-INF directory.
The code I used to accomplish this is the following:


Now, the problem:

If I wish to write the modified properties back to that file that
I just loaded, how do I do that?

Thanks

Zak
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
java.util.Properties.store(OutputStream, String)
[ July 13, 2004: Message edited by: Nathaniel Stoddard ]

Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
and keep in mind that this will always replace the entire file, wiping out whatever comments you may have placed in it.


42
Zak Nixon
Ranch Hand

Joined: Sep 27, 2003
Posts: 126
After looking at your example and my code that was attempting
to save the properties, I am exactly doing what you proposed.

I say: (with the filePath being "/db.properties")



I print the absolute path of the file I am using for the output stream,
and it seems to be trying to find the jakarta-tomcat/bin directory.
Can anyone explain this to me, plus a working solution?

Thanks

Zak
Zak Nixon
Ranch Hand

Joined: Sep 27, 2003
Posts: 126
P.S.

Also, if I change the file path to "db.properties", then I
get a FileNotFoundException......

Zak
Zak Nixon
Ranch Hand

Joined: Sep 27, 2003
Posts: 126
Surely someone is doing the same thing, so please respond....

Thanks

Zak
Zak Nixon
Ranch Hand

Joined: Sep 27, 2003
Posts: 126
I have solved this problem.
Not a problem now, but I will
start a new topic for my new problem.

Zak
Murali Velagapudi
Greenhorn

Joined: Aug 11, 2004
Posts: 2
Nixon

Can you tell me how did able to finish that Writing properties to same properties file ,can you give me the snippet of that

thanks
Murali
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Writing properties to same properties file .
 
Similar Threads
why am I getting this error?
Using Properties File in struts
relative path name for propertiesObject.load()
reading username and password from a property file
Writing to properties file in WEB-INF