📜  Apache Ant复制任务

📅  最后修改于: 2020-12-26 13:52:07             🧑  作者: Mango

Apache Ant复制任务

此任务用于将文件或资源复制到新位置。仅当源文件比目标文件新时才复制。我们还可以使用overwrite属性显式覆盖它。

todir属性用于设置目标路径。该任务使用下面给出的各种属性。

Apache Ant复制任务属性

Attribute Description Required
file The file which is to be copied. Yes
preservelastmodified Preserve last modified name. No
tofile The file to copy to the destination file. if the file attribute is also specified, then only todir is allowed.
todir The destination directory name.
overwrite Overwrite existing files even if the destination files are newer. No
force Overwrite read-only destination files. No
filtering Filter during the copy. No
flatten Copy files by ignoring the directory structure of the source files. No
includeEmptyDirs Copy empty directories. No
failonerror Display error message if copy is failed. No
quiet If true and failonerror is false, then do not log a warning message. No
verbose It logs the files that are being copied. No
encoding Encoding for copying file. No
outputencoding Display the encoding to be used. No

Apache Ant复制任务示例

让我们看一个示例,其中我们将数据从一个文件复制到另一个文件。请参见下面的示例。

复制单个文件

// build.xml


    
        
    

复制文件到目录


    
        
    

将目录复制到另一个目录