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

Writing properties to same properties file .

 
Zak Nixon
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.util.Properties.store(OutputStream, String)
[ July 13, 2004: Message edited by: Nathaniel Stoddard ]
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and keep in mind that this will always replace the entire file, wiping out whatever comments you may have placed in it.
 
Zak Nixon
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S.

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

Zak
 
Zak Nixon
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Surely someone is doing the same thing, so please respond....

Thanks

Zak
 
Zak Nixon
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have solved this problem.
Not a problem now, but I will
start a new topic for my new problem.

Zak
 
Murali Velagapudi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic