How to know whether a property exists or not in a property file in java?
Just load the properties file and then try to get the desired property.
public String getProperty(String key)
Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.
Yet another alternative is to exploit the fact the Properties extends Hashtable<Object,Object>
and use containsKey
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With