Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ANT逐行合并多个文本文件_Ant_Merge_Concat_Ant Contrib - Fatal编程技术网

使用ANT逐行合并多个文本文件

使用ANT逐行合并多个文本文件,ant,merge,concat,ant-contrib,Ant,Merge,Concat,Ant Contrib,如何将多个文本文件合并到一个文件中。我想逐行读取每个文件中的文本,然后将文本合并到最终的输出文件中。我的文件中的示例文本为: 文件1: aaa bbb ccc ddd eee fff ggg hhh iii aaa -->from file 1 ddd -->from file 2 ggg -->from file 3 bbb eee hhh ccc

如何将多个文本文件合并到一个文件中。我想逐行读取每个文件中的文本,然后将文本合并到最终的输出文件中。我的文件中的示例文本为:

文件1:

  aaa  
  bbb  
  ccc  
  ddd  
  eee  
  fff  
  ggg  
  hhh  
  iii  
  aaa  -->from file 1
  ddd  -->from file 2
  ggg  -->from file 3
  bbb  
  eee  
  hhh  
  ccc  
  fff  
  iii 
文件2:

  aaa  
  bbb  
  ccc  
  ddd  
  eee  
  fff  
  ggg  
  hhh  
  iii  
  aaa  -->from file 1
  ddd  -->from file 2
  ggg  -->from file 3
  bbb  
  eee  
  hhh  
  ccc  
  fff  
  iii 
文件3:

  aaa  
  bbb  
  ccc  
  ddd  
  eee  
  fff  
  ggg  
  hhh  
  iii  
  aaa  -->from file 1
  ddd  -->from file 2
  ggg  -->from file 3
  bbb  
  eee  
  hhh  
  ccc  
  fff  
  iii 
预期输出:

  aaa  
  bbb  
  ccc  
  ddd  
  eee  
  fff  
  ggg  
  hhh  
  iii  
  aaa  -->from file 1
  ddd  -->from file 2
  ggg  -->from file 3
  bbb  
  eee  
  hhh  
  ccc  
  fff  
  iii 

我试过下面的目标

<target name="mergeappvars" >  
    <concat destfile="${out.dir}/ApplicationGV.txt" force="no">  
        <fileset dir="${work.dir}/application"  
     includes="*.txt"/>  
    </concat>  
</target>

我的逻辑是一个接一个地追加一个文件,结果是

aaa
bbb
ccc
ddd
eee
fff
ggg
hhh

iii

您需要编写自己的逻辑。此链接将帮助您如何使用ant加载文件和读取文件。

我已经尝试了以下目标