Suppose you have 2 Properties objects. One contains master properties, the other one is a target. Your job is to compare the two.
masterValue = masterProperties.getProperty(masterKey);
for (Properties targetFileProperty : targetFileList) {
if (targetFileProperty.containsKey(masterKey)) {
targetValue = targetFileProperty.getProperty(masterKey);
if (masterValue.equals(targetValue)) { //<---- this is where the problem is
// do something clever
} else {
// do something clever
The problem i am facing in this example is this:
When master key is "A" and master value is "10" and target key is "A" and "target key is " 10 ", code above thinks that these are the same. In other words it is either trimming or ignoring white space.
Can you eithe point out an error in my logic or suggest a better way to assert that white space is not to be ignored? Thank you.