File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Elasticsearch in Action this week in the Big Data 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: 12890
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
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: writing data into a file only some part