Concatenates a file, or a series of files, to a single file or the console. The destination file will be created if it does not exist.
Paths and/or FileSets and/or FileLists are used to select which files are to be concatenated. There is no singular 'file' attribute to specify a single file to cat.
| Attribute | Description | Required |
| destfile | The destination file for the concatenated stream. If not specified the console will be used instead. | No |
| append | Specifies whether or not the file specified by 'destfile' should be appended. Defaults to "no". | No |
| overwrite | Specifies whether or not the file specified by 'destfile' should be written to if is newer that all the source files. Defaults to "yes". | No |
| encoding | Specifies the encoding for the input files. Please see http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html for a list of possible values. Defaults to the platform's default character encoding. | No |
FileSets are used to select files to be concatenated. Note that the order in which the files selected from a fileset are concatenated is not guaranteed. If this is an issue, use multiple filesets or consider using filelists.
FileLists are used to select files to be concatenated. The file ordering in the files attribute will be the same order in which the files are concatenated.
The concat task supports nested FilterChains.
Used to prepend or postpend text into the concatenated stream.
The text may be in-line or be in a file.
| Attribute | Description | Required |
| file | A file to place at the head or tail of the concatenated text. | No |
| trim | Whether to trim the value, default is "no" | No |
| trimleading | Whether to trim leading white space, default is "no" | No |
Concatenate a string to a file:
<concat destfile="README">Hello, World!</concat>
Concatenate a series of files to the console:
<concat>
<fileset dir="messages" includes="*important*"/>
</concat>
Concatenate a single file, appending if the destination file exists:
<concat destfile="NOTES" append="true">
<filelist dir="notes" files="note.txt"/>
</concat>
Concatenate a series of files, update the destination file only if is older that all the source files:
<concat destfile="${docbook.dir}/all-sections.xml"
overwrite="no">
<filelist dir="${docbook.dir}/sections"
files="introduction.xml,overview.xml"/>
<fileset dir="${docbook.dir}"
includes="sections/*.xml"
excludes="introduction.xml,overview.xml"/>
</concat>
Concatenate a series of files, expanding ant properties
<concat destfile="${build.dir}/subs">
<path>
<fileset dir="${src.dir}" includes="*.xml"/>
<pathelement location="build.xml"/>
</path>
<filterchain>
<expandproperties/>
</filterchain>
</concat>
Copyright © 2003 Apache Software Foundation. All Rights Reserved.