Using Ant to Concatenate files

The build.xml file to concatenate files using ant. This can be executed using the command ‘ant “ConcatAll”‘


<?xml version="1.0" encoding="UTF-8"?>
<project name = "MyProj" basedir = "." >

	<target name = "ConcatAll" >
		<concat destfile = "final.txt" fixlastline = "yes" >
			<filelist dir = "."
						files = "first_file.txt
								second_file.txt
								third_file.txt"/>
		</concat>
	</target>

</project>
Author: Binny V A
A philosopher programmer who specializes in backend development and stoicism.

1 thought on “Using Ant to Concatenate files

  1. Hi Binny

    I’am trying to concatenate two files as you said above…
    file1: abcd
    efgh
    file2: ijkl
    mnop
    Running the target for the first time
    abcd
    efgh
    ijkl
    mnop
    Running the target again output is as below
    abcd
    efgh
    ijkl
    mnop
    ijkl
    mnop
    Instead I require the output in the below format
    abce
    efgh
    ijkl
    mnop

    I mean duplicate entries shouldn’t be there…

    can you please tell me the logic

Leave a Reply

Your email address will not be published. Required fields are marked *