Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Does anyone know why the colons are getting escaped when I store the properties file?

I'm doing this:

Properties prop = new Properties();


// Set the properties value.

prop.setProperty("url","http://localhost:7101/test/home");

And storing using:

prop.store(new FileOutputStream(propFile), null);

It's working but the output has colons escaped for some reason:

url=http://localhost:7101/test/home

Anyone know a fix?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
156 views
Welcome To Ask or Share your Answers For Others

1 Answer

In properties files, both of these are legit:

key1 = value
key2: value

So both = and : must be escaped.

Now, if you read the thing back with Properties, it's no problem. Otherwise, you'll have to write custom code


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...