09 November 2005

This is a juvenile problem and too Microsofty. The problem is when Windows-based file names has been stored in a properties file in this way:

my.file=C:\Windows\Kamote

When retrieving that value, the backslashes will be dropped during Properties.load() execution so the resulting string will be:

C:WindowsKamote

Sometimes we have GUI-based configuration managers that we like to be able to store in a properties file or an XML file but want to retrieve the file names with desirable results. Therefore our configuration should look like this:

my.file=C:\\Windows\\Kamote

In order to achieve that, we can use a 2-liner code with JDK's Regular Expression API like this one: