Unfortunately, the Properties class was made to implement Map<Object, Object> when it clearly should have been Map<
String, String>. This was probably because Properties was written long before generics came into the language, and Sun in their infinite wisdom chose to retroactively implement Map<Object, Object> in order to not break backwards compatibility for clients using their Properties in an incredibly stupid way. That is, Properties has always allowed people to put things other than Strings in as either keys or values, if they use put() rather than setProperty(), even though only an insane person would ever do this. Rather than fix this error, Sun chose to continue it. That's why you can't simply use "String key : props.keySet()" as you would expect.
Here's another alternative: