Ant如何将从文件中读取的值读入属性值?

时间:2009-05-05 08:42:31

标签: ant build-process build properties

该文件如下:

a1,b1
a2,b2
...

我知道值“a2”。 如何将值“b2”转换为属性值。

我知道如何通过以下方式选择包含“a2”的行:

<linecontains>
  <contains value="a2"/>
</linecontains>

我不知道如何将属性值设置为“b2”。 我随时准备了更多其他信息。

1 个答案:

答案 0 :(得分:21)

以下是我的诀窍:

<loadfile srcfile="data" property="result">
     <filterchain>
           <linecontains>
                <contains value="a2"/>
           </linecontains>
           <tokenfilter>
                <replacestring from="a2," to=""/>
           </tokenfilter>
    </filterchain>
</loadfile>
<echo message="${result}"/>

正如您所指出的那样,首先选择'a2'。然后令牌过滤器替换a2和冒号。希望有所帮助。