概述
1.说明: 这种文件需要有一定的格式才能被java.util.Properties包读取。主要用在java相关的技术上,用来存储应用的可配置参数。
- 每个实体都占一行,有如下两种格式。两个字符串参数,左边是键,右边是值。
1)propertyName=propertyValue
2)propertyName:propertyValue - 在键与值之间的空格会被忽略。下面两个是等效的。
name=Stephen
name = Stephen
且在每一行的开始部分空格也会被忽略。 - 注释用 # 号或 ! 号开始,会被忽略。且空白行也会被忽略。
- 值一般会处于行的末尾部分,末尾如有空格,也包括在值里。
- 续行符, + 换行符
message = Welcome to
Wikipedia!
等同于 message = Welcome to Wikipedia!
注意:每一行的开始部分空格也会被忽略
- 转义字符, 表示,n表示换行,r 表示carriage return,t表示tab
- 使用Unicode,u开头,比如,u002c
2.例子: CSDN不支持properties格式代码块,我用Typora软件编辑markdown的话支持。
# 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 precede 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!
# But if the number of backslashes at the end of the line is even, the next line is not included in the value. In the following example, the value for "key" is "valueOverOneLine"
key = valueOverOneLine\
# This line is not included in the value for "key"
# Add spaces to the key
key with spaces = This is the value that could be looked up with the key "key with spaces".
# The characters = and : in the key must be escaped as well:
key:with=colonAndEqualsSign = This is the value for the key "key:with=colonAndEqualsSign"
# 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
3.参考文章:
1.https://en.wikipedia.org/wiki/.properties
2.ATG Programming Guide:Properties File Format
最后
以上就是飞快奇异果为你收集整理的.properties文件的格式的全部内容,希望文章能够帮你解决.properties文件的格式所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复