Get number of entries in properties file apache commons

I’m creating a list of IP address’ to ping in which a user can add to the list which is then saved to a properties file in the form of site.name1 = … site.name2 = …

Currently I have a for loop with a fixed amount, is there a way to get the number of entries in a properties file so I can set this in the for loop rather than wait for a exception?

 PropertiesConfiguration config = File(""));
            //initially check for how many values there are - set to max increments for loop
            for (int i = 0; i < 3; i++) { //todo fix
                siteName = config.getString("" + i);
                siteAddress = config.getString("site.address" + i);
                SiteList.add(i, siteName);
                IPList.add(i, siteAddress);

I’ve looked through the documentation and other questions but they seem to be unrelated.

Leave a Reply

Your email address will not be published. Required fields are marked *