The code above from Alan Moore has two problems:
1) it doesn't take advantage of appendReplacement properly
2) it doesn't account for null pointers or unmatched properties
Here is a slight tweak to the code that resolves those issues:
Of course, nowadays, there are plenty of frameworks that handle this kind of thing for us like Spring's
PropertyPlaceholderHelper.