Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2005

Tip: Looking for answers? Try searching our database.

modifying properties

Thread view: 
Sam - 19 May 2005 21:05 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.