ant:如何比较两个文件的内容 [英] ant: how to compare contents of two files

查看:34
本文介绍了ant:如何比较两个文件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 ANT 比较两个文件(比如 file1.txt、file2.txt)的内容.

如果文件内容相同,则应将某些属性"设置为 true,如果内容不同,则应将属性"设置为 false.

谁能建议我任何可以做到这一点的 ANT 任务.

提前致谢.

解决方案

您可以使用以下内容:

<filesmatch file1="file1"file2="file2"/></条件>

这只会在文件相同时设置属性.然后,您可以使用

检查该属性

...</目标>

这在 ant 中可用,没有添加依赖项,请参阅此处了解其他条件.>

I want to compare the contents of two files (say file1.txt,file2.txt) using ANT.

if files content are same then it should set some 'property' to true, if contents are not same then it should set the 'property' as false.

Can anyone suggest me any ANT task that can do this.

Thanks in advance.

解决方案

You can use something like:

<condition property="property" value="true">
  <filesmatch file1="file1"
              file2="file2"/>
</condition>

This will set the property only if the files are the same. You can then check for the property, using

<target name="foo" if="property">
...
</target>

This is available in ant, with no added dependency, see here for other conditions.

这篇关于ant:如何比较两个文件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆