mercredi 6 octobre 2021

equalsIgnoreCase and contains check if a string matches from property file key value

I have a property file in which I have declared a key value as below:

prop.key = Abc

In my Java code, I have to check if a string coming from database is equal to the string present in property file. Here is my code:

protected static final String PROPERTY_VALUE = "prop.key";

String str = "Abc";
if (!properties.getProperty(PROPERTY_VALUE).equalsIgnoreCase(str)) {
    //do processing;
}
else {
    //do nothing;
}

Is my logic/condition correct? If not, then what would be the correct logic?

Aucun commentaire:

Enregistrer un commentaire