Skip to content
Advertisement

Tag: property-files

Throw exception when a property is duplicated in a properties file

How can I throw an Exception when a properties file contains a duplicate property? Here is an example demonstrating this situation: Answer I suppose you are reading the file with something like Properties.load(). It sets the parameter internally using put(key, value). You can override that method to get the desired behaviour like e.g. EDIT: Integrating this into the OP’s code:

Advertisement