• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

writing data into a file only some part

 
Chennarao Marvatu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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");
sb1.append("\r\n");
sb1.append("NotificationServerName=");sb1.append(notificationServ);
sb1.append("\r\n");
sb1.append("NotificationServerUName=");sb1.append(notificationUser);
sb1.append("\r\n");
sb1.append("NotificationServerPwd=");sb1.append(notificationPass);
sb1.append("\r\n");
System.out.println("PROPERTIES FROM SERVER"+sb1);
FileWriter f = new FileWriter(iniFilePath,true);
f.write(sb.toString());
f.close();


Thanks
Chennarao
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Bill
 
Shekar Atmakur
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic