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: # Properties-file directory=D:\media\D-Downloads\Errorfile\…