The Artima Developer Community
Sponsored Link

Java Answers Forum
retaining the format of the properties file while saving it from Java!!!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
ramqqq

Posts: 2
Nickname: ramqqq
Registered: Oct, 2005

retaining the format of the properties file while saving it from Java!!! Posted: Jun 20, 2006 11:01 PM
Reply to this message Reply
Advertisement
Hi,

I've a aab.properties file. I'm modifying the property of this file at runtime and saving the .properties file.

Lets Say

aab.properties has the following values

#added by rrqqq
one=1

#added by sam
aab=2


======================

1.when i do a save from java using the following code, the format of the properties file gets changed. How can i retain the same format? format means the spaces or blank line are ignored, i want to retain the blank line and comments.

2. How can i retain the same order? once the properties file is saved in java, aab is preceded before one, but i want to retain the same order one should be following by the key aab in the properties file. Is there a way to do that.

Properties props = new Properties();
props.load(new FileInputStream("aab.properties"));
props.setProperty("aab", "hello");
props.store(new FileOutputStream("aab.properties"), "Encrypted Password");

thanks

Topic: Converting/formatting a date Previous Topic   Next Topic Topic: java.sql.SQLException: Connection is closed.0

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use