Ant 如何将从文件中读取的值转换为属性值? [英] How Ant can get a value read from a file into a property value?

查看:20
本文介绍了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.

这篇关于Ant 如何将从文件中读取的值转换为属性值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆