更新时间:2022-12-05 22:34:48
这是有点类似these.
属性从文件的properties.txt
加载。
这里的弱点是,在您输入文本的 $ {
所有出现被转换为 {
的前令牌替换 - 如果该字符串出现在文本其他地方这很可能打破东西。如果这是一个问题,它仍然奥特可以适应该溶液中。
Properties are loaded from the file properties.txt
.
The weakness here is that all occurrences of ${
in your input text are converted to {
before the token substitution - which may well break things if that string appears elsewhere in the text. If that is a problem, it still aught to be possible to adapt this solution.
<copy file="input.txt" tofile="output.txt">
<filterchain>
<replaceregex pattern="\$\{" replace="{" />
<filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
<param type="propertiesfile" value="properties.txt"/>
<param type="tokenchar" name="begintoken" value="{"/>
<param type="tokenchar" name="endtoken" value="}"/>
</filterreader>
</filterchain>
</copy>