aspose file tools
The moose likes Java in General and the fly likes Properties file issue Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Properties file issue" Watch "Properties file issue" New topic
Author

Properties file issue

Keerthi Chandhu
Greenhorn

Joined: Feb 03, 2009
Posts: 16
Hi,

I am trying to modify a .properties file in a jsp screen and save the modified content in the properties file.

my file data looks like this
Before modification

Key1=value1
key2 = value2
###comments#####

After modification
ey1=value1 //missing first letter while saving
key2 = null
// saving null value due to having space between "=" sign
###comments#####

I am having two issues while saving:
(i) If there is space between "=" sign like Key2 = value2 then it is saving as null value like this key2 = null
(ii) If the charAT(0) is not space or # at the starting line of my property file then it is saving that property missing first letter of the key.


Could anyone suggest how to make this work properly?


Thank you
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24061
    
  13

Well... how are you doing it now? The Properties class has decent read/write routines of its own; are you using these?


[Jess in Action][AskingGoodQuestions]
Keerthi Chandhu
Greenhorn

Joined: Feb 03, 2009
Posts: 16
Hi,

Yes, I am using the following method to write into properties file.Properties props = new Properties();

but as we know we can't retain comments.To save comments I am using some logic


and I am facing the above issues as I mentioned in my previous message.

(i) If there is space between "=" sign like Key2 = value2 then it is saving as null value like this key2 = null
(ii) If the charAT(0) is not space or # at the starting line of my property file then it is saving that property missing first letter of the key.

Could anyone suggest me how to make this work properly?



Thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Properties file issue
 
Similar Threads
pass more than one parameter at the web services client
Converting property file to object model
midlet.platformRequest(string) problem for multiple request parameters in url
how to reference already defined property as the value for another key in the properties file.
Replacing a word in a text file