fasionchan

读万卷书,行万里路,品万味肴,撸万行码。

配置文件格式

.properties

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# You are reading the ".properties" entry.
! The exclamation mark can also mark text as comments.
# The key characters =, and : should be written with
# a preceding backslash to ensure that they are properly loaded.
# However, there is no need to preceede the value characters =, and : by a backslash.
website = https://en.wikipedia.org/
language = English
# The backslash below tells the application to continue reading
# the value onto the next line.
message = Welcome to \
          Wikipedia!
# Add spaces to the key
key\ with\ spaces = This is the value that could be looked up with the key "key with spaces".
# Unicode
tab : \u0009
# If you want your property to include a backslash, it should be escaped by another backslash
path=c:\\wiki\\templates
# However, some editors will handle this automatically

Java

1
2
3
4
5
6
InputStream in = new FileInputStream("/xxxx/xxxx");

Properties properties = new Properties();
properties.load(in);

String value = properties.get("some_key");

Python

1
2
3
import jprops
with open('mine.properties') as fp:
  properties = jprops.load_properties(fp)

Comments