Getting Properties to detect Duplicates
I have a config file containing lots of key=Value lines
I use java.util.Properties to read this in.
I only want all the keys to be distinct (as it works in Properties)
BUT I want Properties to throw an error/warning if there is a duplicate entry rather than to do it silently.
Or how do I check for duplications?
Hi,You can't check for duplicates if you are loading using Properties, you can only do that if you load and parse the file on your own./Kaj
I know that Properties does not contain duplicates.
Its just that I've fouond that I have duplicates in the files I am reading in and I wanted a way to detect these. (without rewriting the Properties class)
I achieved it by creating a DuplicateHoldingProperties class that extends Properties. It basically just overrided the put() method to save all the entrys that were already in the Properties Map, then called super.put() anyway so the class worked the same. (I also put in a method to get the duplicated Entrys.)