【发布时间】:2015-08-01 11:51:56
【问题描述】:
我有一个像这样的给定属性文件:
firstvalue=1
secondvalue=hello
我使用这个 Ant 脚本来改变一个值:
<propertyfile file="A.properties">
<entry key="firstvalue" value="2" />
</propertyfile>
执行脚本后,属性文件现在是:
#Wed, 20 May 2015 11:42:46 +0200
=
firstvalue=2
secondvalue=hello
我明白为什么 Ant 任务会添加带有日期的注释,但为什么 Ant 还要在第二行添加这个符号 equal?
我认为这是由于编码文件造成的,因为我无法用我的所有属性文件重现问题,而只能重现其他人手动制作的一些文件。在 Ant 中使用文件之前,有没有办法避免这种行为或修复编码?
编辑: 这是我的属性文件,在脚本之前使用在线 hexdump 工具查看: 文件名:A.properties 哑剧类型:
0000-0010: ef bb bf 0d-0a 66 69 72-73 74 76 61-6c 75 65 3d .....fir stvalue=
0000-0020: 31 0d 0a 73-65 63 6f 6e-64 76 61 6c-75 65 3d 68 1..secon dvalue=h
0000-0024: 65 6c 6c 6f
ello
之后是同一个文件:
file name: A.properties
mime type:
0000-0010: 23 54 68 75-2c 20 32 31-20 4d 61 79-20 32 30 31 #Thu,.21 .May.201
0000-0020: 35 20 31 35-3a 32 31 3a-31 32 20 2b-30 32 30 30 5.15:21: 12.+0200
0000-0030: 0d 0a ef bb-bf 3d 0d 0a-66 69 72 73-74 76 61 6c .....=.. firstval
0000-0040: 75 65 3d 32-0d 0a 73 65-63 6f 6e 64-76 61 6c 75 ue=2..se condvalu
0000-0049: 65 3d 68 65-6c 6c 6f 0d-0a e=hello. .
【问题讨论】:
-
我会运行 xxd(或者找一些在线的 hexdump 工具)。否则,人们将很难猜出问题所在。
-
我在执行脚本之前和之后都有我的文件的十六进制转储。
标签: encoding ant properties-file