[英]How Ant can get a value read from a file into a property value?
The file looks like: 该文件看起来像:
a1,b1
a2,b2
...
I know the value "a2". 我知道价值“a2”。 How to get the value "b2" into a property value.
如何将值“b2”转换为属性值。
I know how to select line which contains "a2" by: 我知道如何通过以下方式选择包含“a2”的行:
<linecontains>
<contains value="a2"/>
</linecontains>
But I do not know how to set a property value to "b2". 但我不知道如何将属性值设置为“b2”。 I am at your disposal for more other information.
我随时为您提供更多其他信息。
The following does the trick for me: 以下是我的诀窍:
<loadfile srcfile="data" property="result">
<filterchain>
<linecontains>
<contains value="a2"/>
</linecontains>
<tokenfilter>
<replacestring from="a2," to=""/>
</tokenfilter>
</filterchain>
</loadfile>
<echo message="${result}"/>
As you pointed out, first the line the the 'a2' will be selected. 正如您所指出的那样,首先选择'a2'。 The tokenfilter then replaces a2 and the colon with nothing.
然后令牌过滤器替换a2和冒号。 Hope that helps.
希望有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.