Property question

L

lallous

Hello,

I noticed that the Property class, when parsing values such as:
myKey=myvalue\myvalu1\myasdqd
myPath=c:\games\theGame\

Then all '\' are removed.

Any solution to keep the backslash w/o having the user manually replace all
backslash with forward slash?
 
C

Christophe Vanfleteren

lallous said:
Hello,

I noticed that the Property class, when parsing values such as:
myKey=myvalue\myvalu1\myasdqd
myPath=c:\games\theGame\

Then all '\' are removed.

Any solution to keep the backslash w/o having the user manually replace
all backslash with forward slash?

Yes, they'll need to double quote:

myKey=myvalue\\myvalu1\\myasdqd

but that's not much better than replacing the backslash with a forward
slash.

You have to do this because \ has a special meaning in a properties file.
Look at the api docs for the java.util.Properties.load() method for an
explanation on this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top