结果中有新行的 apache ant loadfile

apache ant loadfile with new line in the results

我正在尝试使用 Apache Ant 中的 LoadFile 来读取其中只有日期的文件。我正在使用此日期生成带有附加日期的目标文件。

`<loadfile property="DATE" srcFile="DATE.txt" />`

源文件:ABC.txt 目标文件:ABC_${DATE}.txt 文件DATE.txt内容为10182017

但是目标文件正在创建为 字母表

_10182017.txt

有什么方法可以在从文件中读取日期时避开 new/next 行?

您可以使用嵌套的 filterchain 函数解决此问题。

<loadfile property="DATE" srcfile="DATE.txt">
    <filterchain>
        <striplinebreaks />
    </filterchain>
</loadfile>

查看 https://ant.apache.org/manual/Types/filterchain.html 了解更多详情。