Can some tell me the easiest way to remove a system property. I tried with
System.setProperty("myProperty", null);
It didn't work.
Regards,
Wei
What do you mean by "remove" in this case? What is end effect you want
to have? Just that System.getProperty will return null?
--
Jon Skeet - <sk...@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Properties extends Hashtable, so
System.getProperties().remove("myProperty") might be what you are
looking for.
Keep in mind though that many of the properties are only informative,
so changing or removing them doesn't affect anything but the set of
properties itself.
/gordon
--
[ do not send me private copies of your followups ]
g o r d o n . b e a t o n @ e r i c s s o n . c o m
String oldPropery = System.getProperty("somGlobalPropery");
System.setProeprty("somGlobalPropery", "myValue");
// do somthing
......
// set it back
System.setProeprty("somGlobalPropery", oldProperty); // fails if
oldProperty is null
Wei
Jon Skeet <sk...@pobox.com> wrote in message news:<MPG.1638b4a36...@mrmog.peramon.com>...
Right. What I suggest you do is use System.setProperties() instead -
when you want to make a change, do something like:
Properties previousProps = System.getProperties();
Properties newProps = new Properties (previousProps);
newProps.setProperty ("foo", "bar");
System.setProperties (newProps);
then later:
System.setProperties (previousProps);
Note that you'll get in trouble with this if you do this in different
places in an overlapping way.