Apache Ant Copy Task
This task is used to copy file or resource to a new location. It copies only if the source files is newer than the destination file. We can also explicitly overwrite it by using overwrite attribute.
The todir attribute is used to set the destination path. This task uses various attributes which are given below.
Apache Ant Copy Task Attributes
||The file which is to be copied.
||Preserve last modified name.
||The file to copy to the destination file.
||if the file attribute is also specified, then only todir is allowed.
||The destination directory name.
||Overwrite existing files even if the destination files are newer.
||Overwrite read-only destination files.
||Filter during the copy.
||Copy files by ignoring the directory structure of the source files.
||Copy empty directories.
||Display error message if copy is failed.
||If true and failonerror is false, then do not log a warning message.
||It logs the files that are being copied.
||Encoding for copying file.
||Display the encoding to be used.
Apache Ant Copy Task Example
Lets see an example in which we are copying data from one file to another. See the example below.
Copy single file
Copy file to directory
Copy directory to another directory