The moose likes I/O and Streams and the fly likes Updating Properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Updating Properties file" Watch "Updating Properties file" New topic

Updating Properties file

Dinesh Bang
Ranch Hand

Joined: Jun 15, 2006
Posts: 52
Hi Ranchers,

I want to update the properties file without changing the sequence of key,value pairs.
When I do it using Java.util.Proeprties.setProperty , the format of file is lost, although the data gets persisted.

Is there any way out ?

Thanks in advance

SCJP 1.4,SCBCD 1.3, SCWCD 1.5, ???
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41062
You could extend the Properties with your own class that overrides the "load" and "store" method with versions that remember (load) and honor (store) the order of the original file. If you start with the code of the original methods, that shouldn't be too hard.

Ping & DNS - my free Android networking tools app
I agree. Here's the link: http://aspose.com/file-tools
subject: Updating Properties file
Similar Threads
Common resource for all configurable parameters.
Replace with Properties
using two properties files in struts
B&S suncertify.properties
How not to hard-code file location in java?