In order to avoid ConcurrentModificationException, i am resorting to the following:
List<String> tobeRemoved = new ArrayList<String>();
for (Object propertyKey : suppliedContent.keySet()) {
key = (String) propertyKey;
if (EqualityUtils.isMatching(rgx, key)) {
tobeRemoved.add(key);
}
}
for (String o : tobeRemoved) {
suppliedContent.remove(o);
}
Is there a cleaner way?
I think using
iteratorand callremove()oniteratorwhen matching would do same.EDIT: Hand typed code. There may be syntax errors.