# Java Properties Class: getProperty() question

Hi

Im using Properties class to read my configuration.ini file which contains variables for my program.

And one of the variables is for a directory path:

directory = C:\some\directory

now the problem is: if i use getProperty

String path = prop.getProperty("directory");

it stripped the "\" off !!

I supposed i could add another \ in the configuration.ini. But is there any other way to do it better? Because someone might go to configuration.ini file and change the directory manually without knowing another "\" required to make it work.

Help..

And im really sorry bout the small point, im running out of points here :(

###### Who is Participating?

Commented:
directory = C:\\some\\directory

OR

directory = C:/some/directory
0

Commented:
Quick explanation as to why:

When you deal with Strings the \ character indicates that we want to escape the next character, and the only valid escape characters are
\b \t \n \f \r \" \' \\
It looks as if you may have b, t, n, n or r as the first character of your directory, so you wouldn't have got an error from it.

As suggested by TimYates, you can use the escaped version of the \ character: \\ or, what I believe to be the more common approach, use the Unix style path seperator of /.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.