Ant 替换某一文件中的字符串

A.替换某一文件中的字符串

<replace file ="base/testing.txt">
token="@temp@"
value="${newstring}"
</replace>

解释:token是需要替换的标记;value是新值,将testing.txt文件中的@temp@替换为新值。

B.替换某个文件夹中存在特定标记的文件

<replace dir="temp" token="@CHARSET@" value="${webapp.charset}"/>

解释:temp目录中文件,如果有存在@CHARSET@标记的,将被替换为${webapp.charset}变量值。

C.批量替换

<replace dir="dist" includes="${app.project}.jad" encoding="UTF-8">

<replacefilter token="@NAME@" value="${app.name}"/>
<replacefilter token="@VENDOR@" value="${app.vendor}"/>
<replacefilter token="@MIDLET@" value="${app.midlet}"/>
<replacefilter token="@JAR@" value="${app.project}"/>
<replacefilter token="@FILESIZE@" value="${size}"/>
<replacefilter token="@DESCRIPTION@" value="${app.description}"/> <replacefilter token="@PRICE@" value="${app.price}"/>

</replace>

原文地址:https://www.cnblogs.com/balaamwe/p/2382065.html