This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Java in General and the fly likes writing data into a file only some part Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "writing data into a file only some part" Watch "writing data into a file only some part" New topic

writing data into a file only some part

Chennarao Marvatu
Ranch Hand

Joined: Aug 09, 2004
Posts: 32
Hello Friends ,
I have to modify my client property file every time
i.e. i need to overwrite some part of my property file
how can do that i have dome like this but not working
Here i have to modify NotificationServer part only when i login into the
system.pls help me out

HashMap versionUpdates=secReqObject.getVersionInfo();
//here versionUpdate is the Server peroperty Object

String notificationServ = (String)versionUpdates.get("NotificationServerName");
String notificationUser = (String)versionUpdates.get("NotificationServerUName");
String notificationPass = (String)versionUpdates.get("NotificationServerPwd");

StringBuffer sb1 = new StringBuffer();
sb1.append("###NOTIFICATION SERVER");
System.out.println("PROPERTIES FROM SERVER"+sb1);
FileWriter f = new FileWriter(iniFilePath,true);


William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13018
There is nothing to be gained by trying to modifiy your properties file this way. Just use the methods in the java.util.Properties class to set the new values and write the whole thing back out to the file. Much simpler.
Shekar Atmakur
Ranch Hand

Joined: Oct 24, 2003
Posts: 36
If you use ANT to do your builds, and if that file needs to change at compile time then ANt can do the job for you pretty efficiently
I agree. Here's the link:
subject: writing data into a file only some part
jQuery in Action, 3rd edition