Ant 的 replace 操作

replace 可以替换某个文件中的字符串。

<?xml version="1.0" encoding="UTF-8"?>
<project name="testCondition">
    <replace file="testfile1.txt"    token="hello"     value="world"/>
</project>

结果就把 testfile1.txt 中的 "hello" 替换成了 "world".

也可以批量处理:

<?xml version="1.0" encoding="UTF-8"?>
<project name="testCondition">
    <replace dir="." includes="*.txt" encoding="UTF-8">
        <replacefilter token="this" value="that"/>
        <replacefilter token="o" value="00"/>
    </replace>
</project>

就把当前文件夹下面所有 txt 文件按照指定的 filter 替换了。

 

posted @ 2013-01-05 23:06  allenbackpacker  阅读(4685)  评论(0编辑  收藏  举报