[英]Compare two strings in ANT
Hy! !
I have to compare two strings in ANT with <equals>
task but even if the console show the correctly string, It's doesn't work for my code. 我必须将ANT中的两个字符串与
<equals>
任务进行比较,但是即使控制台显示正确的字符串,它也不适用于我的代码。 This is the code : 这是代码:
<echo file="file.txt" append="true">AB${line.separator}</echo>
<echo file="file.txt" append="true">CD${line.separator}</echo>
<loadfile property="content" srcFile="file.txt">
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.HeadFilter">
<param name="lines" value="1" />
</filterreader>
</filterchain>
</loadfile>
<echo>${content}</echo>
<if>
<equals arg1="${content}" arg2="AB" />
<then><echo message="OK"/></then>
<else><echo message="not OK"/></else>
</if>
the result of the build is : 构建的结果是:
11:24:23 [echo] AB
11:24:23 [echo] not OK
Can you tell me how to fix this please? 你能告诉我如何解决这个问题吗? and thnks :)
和thnks :)
I suspect arg2
attribute is missing the line separator. 我怀疑
arg2
属性缺少行分隔符。 Try this: 尝试这个:
<equals arg1="${content}" arg2="AB${line.separator}" />
Or, even better, try to clean content
of all line separators. 或者,甚至更好地,尝试清理所有行分隔符的
content
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.