Ant 如何将从文件中读取的值转换为属性值?
问题描述:
文件看起来像:
a1,b1
a2,b2
...
我知道值a2".如何将值b2"转化为属性值.
I know the value "a2". How to get the value "b2" into a property value.
我知道如何通过以下方式选择包含a2"的行:
I know how to select line which contains "a2" by:
<linecontains>
<contains value="a2"/>
</linecontains>
但是我不知道如何将属性值设置为b2".我随时为您提供更多信息.
But I do not know how to set a property value to "b2". I am at your disposal for more other information.
答
以下对我有用:
<loadfile srcfile="data" property="result">
<filterchain>
<linecontains>
<contains value="a2"/>
</linecontains>
<tokenfilter>
<replacestring from="a2," to=""/>
</tokenfilter>
</filterchain>
</loadfile>
<echo message="${result}"/>
正如您所指出的,首先将选择a2"行.然后令牌过滤器将 a2 和冒号替换为空.希望有所帮助.
As you pointed out, first the line the the 'a2' will be selected. The tokenfilter then replaces a2 and the colon with nothing. Hope that helps.