Hi Folks,
How do I modify a property value which I have read using the
getProperty() method of java. I treid using setproperty() but it writes
a new file with date/time and erases my old property values.
For eg:
#
#Thu May 19 15:56:43 EDT 2005
delay=100
This is what I get when I try to read the same property file which has
the following values :
bytesread=100
delay=60
dir=C:\projects
any idea how do i do it.
Thanx in advance,
Sam
Arnaud Berger - 20 May 2005 08:31 GMT
Hi,
What you usually do is :
Properties props= Properties.load(new FileInputStream("myprops.properties");
props.setProperty("delay","200");
props.store(new FileOutputStream("myprops.properties"));
The "store" method of the Properties class will always overwrite the file
completely, writing only the properties this object contains.
This is why you should create your Properties object with a "load" from the
file, to be sure that no property
will be missing when you "store" back.
Regards,
Arnaud
> Hi Folks,
>
[quoted text clipped - 17 lines]
>
> Sam