0

I have several backslashes ("\") in a properties file. This is what the file looks like:

dir=\\127.0.0.1\d$\dir\dir2\dir3

This results in the string 127.0.0.1d$dirdir2dir3 when the property dir is used in the code.

I have tried unicode escapes like this:

dir=\u005C\u005C127.0.0.1\u005Cd$\u005Cdir\u005Cdir2\u005Cdir3

I have also tried backslash as escape like this:

dir=\\\\127.0.0.1\\d$\\dir\\dir2\\dir3

Both of the tries above results in the string \\127.0.0.1d$dirdir2dir3 when the property dir is used in the code.

I want the property dir to be set to \\127.0.0.1\d$\dir\dir2\dir3 when the property is used in the code. What shall the .properties-file look like to get this result?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
user1766169
  • 1,932
  • 3
  • 22
  • 44
  • @Tunaki I have edited my post. Is it possible to use Properties.load() when the properties are read using annotation? – user1766169 Aug 08 '16 at 11:19
  • Oh that is a very different question, because I assume you're using Spring behind this to inject the value. You should ask a new question with your Spring config instead of editing this one, but make sure you read this question before http://stackoverflow.com/questions/37858207/backslash-in-proprties-file-is-being-ignored-by-springs-environment-vari. – Tunaki Aug 08 '16 at 11:34
  • 1
    @Tunaki Ok. I have asked a new question here: http://stackoverflow.com/questions/38828523/special-characters-in-properties-file – user1766169 Aug 08 '16 at 11:56

0 Answers0