commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christian Koncilia" <Christian.Konci...@panoratio.de>
Subject AW: Commons Configuration: delete entry
Date Tue, 08 Aug 2006 05:40:15 GMT
Hi Oliver,

thats what I tried before but it doesn't work neither. Another strange thing, if I use "config.clear()"
to clear the whole properties file, everything except(!) the last thing I read is deleted...

This looks to me like some internal bug. Or do you have another idea?

Bye
    Christian

-----Urspr√ľngliche Nachricht-----
Von: Oliver Heger [mailto:oliver.heger@oliver-heger.de]
Gesendet: Mo 07.08.2006 21:53
An: Jakarta Commons Users List
Betreff: Re: Commons Configuration: delete entry
 
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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message