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

Categories

0 votes
170 views
in Technique[技术] by (71.8m points)

java - Saving to properties file escapes :

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

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

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...