commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@oliver-heger.de>
Subject Re: Commons Configuration: delete entry
Date Mon, 07 Aug 2006 19:53:39 GMT
Christian Koncilia wrote:
> Hello everybody,
> 
> I have a question regarding the Commons Configuration. Let's assume I
> have a configuration file "myprops.properties" that looks like this:
> 
>> -------------------------
> # written by PropertiesConfiguration
> # Mon Aug 07 08:29:12 CEST 2006
> 
> group1.entry1 = value1
> group1.entry2 = value2
> group1.entry3 = value3
>> -------------------------
> 
> Now I would like to simply delete an entry. For instance, I would like
> to remove the whole line "group1.entry2 = value2" from my properties
> file. How do I do this?
> 
> Using
> 
>   PropertiesConfiguration config = 
>             new PropertiesConfiguration("myprops.properties");
>   config.clearProperty("group1.entry2 = value2");
>   config.save();
> 
> doesn't work. 
> 
> Thanks for your help!
> 
> Bye
>     Christian
> 
You only need to pass in the key of the property you want to delete to 
clearProperty(), so the line in question should run:

config.clearProperty("group1.entry2");

HTH
Oliver

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message