I use java.lang.properties to read config file and assign the config values to class’s fields. But I don’t want to set all the properties in config file. That means, some fields can have default values and be omitted in config file.
So my code should be something like this:
if(properties.getProperty("key")!=null){
value = properties.getProperty("key");
}
But there are so many fields to be coded like this. Is there a way to avoid this boring work?
Use a default value argument instead:
If the key is not found in this property list, it will use the default value.
P.S. de bene esse, eg.
value = properties.getProperty("key", "blabla, this is default value");