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文件的格式相关推荐

  1. 读取/书写Java的XML格式properties文件

    转载自  读取/书写Java的XML格式properties文件 在JDK5中,properties文件的格式可以由XML构成,这里给出了一个读取/书写XML格式properties文件的例子. 因为 ...

  2. Properties文件的XML格式

    转载自 Properties文件的XML格式 想必大家都用过*.properties文件,作为配置文件.但是,如果该文件写入了中文,待编译后内容就会成为乱码,使用native命令也好.使用ant执行编 ...

  3. 解决eclipse中properties文件为\u格式的乱码

    问题描述:eclipse中的properties文件为乱码.格式:\u4213等 设置properties的文件格式,如下图: 然后修改当前properties配置文件的格式,: 右键Properti ...

  4. eclipse中 properties文件编码问题

    1. Eclipse修改设置 项目中用到了配置文件,所以在Eclipse中新建.properties文件,文件中编辑了中文,在保存时Eclipse报出以下错误: 解决这个问题的方法: 依次选择: 菜单 ...

  5. 微服务,微架构[五]之springboot读取properties文件

    介绍 很多项目中都会有配置文件,比如说配置 数据库的连接项目常量定义等等参数配置,那么这些参数在项目启动的时候就会被读到指定的容器中,可供项目初始化将必要的对象都初始化完成,如果参数配置错误或参数没有 ...

  6. spring核心配置文件引入外部properties文件和另外的xml配置文件

    spring核心配置文件引入外部properties文件和另外的xml配置文件 为什么要引入外部文件 我们使用jdbc的时候,会创建一个jdbc.properties配置文件,如果我需要在spring ...

  7. 使用ResourceBundle加载properties文件

    使用ResourceBundle加载properties文件 @(JAVA)[java] 1.ResourceBundle介绍 说的简单点,这个类的作用就是读取资源属性文件(properties),然 ...

  8. 使用C语言读取properties文件V1.0

    本程序使用C语言读取类似以下格式的properties文件. path = /etc/wgetrc launch_on_start = true 下一版目标: (1)使用指针代替二维数据或者二维数据的 ...

  9. java对文件的操作详解_Java 对 Properties 文件的操作详解及简单实例

    Java 对 Properties 文件的操作详解及简单实例 发布于 2020-8-7| 复制链接 摘记: Java 对 Properties 文件的操作简介在 Java 中,我们常用 java.ut ...

最新文章

  1. MySqlClient访问tinyint字段返回布尔值
  2. RDD的几种创建方式
  3. [转]【JAVA各版本特性】JAVA 1.0
  4. Java Collections API怪癖
  5. 2ab对应的c语言表达式是,编译原理 作业标准答案
  6. error: expected unqualified-id extern C {
  7. 计算机网络原理的思维导图汇总
  8. 微信消息实现自动推送--方式一 成功啦 进来学
  9. XDT——基于Python的XSS自动化检测工具
  10. php hash 文件,php对文件进行hash运算
  11. 三次握手的过程、四次挥手、为什么要进行第三次握手、为什么要进行四次挥手
  12. TCP三次握手中SYN,ACK,seq ack的含义
  13. 学习笔记4 环境试验箱的校准
  14. 实时音视频技术(WebRTC/voip/Linphone/P2P)
  15. linux设置定时任务(crontab)
  16. mysql事务隔离级别之锁实现原理,脏读、不可重复读、幻读出现原因及解决方案
  17. 机器人动力学方程的四种形式
  18. 掀开高级游戏黑客的面纱,教你打造游戏修改器
  19. 矩阵乘以矩阵的转置的秩等于矩阵的秩
  20. Android 导出.vcf格式通讯录方法

热门文章

  1. iOS文字轮播简单实现(UILabel)
  2. 为何你一身本领,却还是逃不过写烂代码的命运?
  3. linux卸载软件的命令,「Ubuntu命令」常用安装软件和卸载软件包命令
  4. R语言:蒙特卡洛方法求积分
  5. android textview 获得行数,android中提前获取TextView行数
  6. MySQL 数据备份与恢复(小学生篇)
  7. 编写STM32 C程序:字符串String转数字, 数字转字符串String
  8. java jmx 开启_动态开启jmx服务
  9. 论文阅读 [TPAMI-2022] Disentangling Monocular 3D Object Detection: From Single to Multi-Class Recognitio
  10. 计算机派位志愿填报技巧,广州公办初中入学途径+志愿填报技巧,太实用了