java left logo
java middle logo
java right logo
 

Home arrow Other API Tips
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4100
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to use Delete task E-mail
User Rating: / 13
PoorBest 

Delete

Description

Deletes a single file, a specified directory and all its files and subdirectories, or a set of files specified by one or more FileSets. When specifying a set of files, empty directories are not removed by default. To remove empty directories, use the includeEmptyDirs attribute.

If you use this task to delete temporary files created by editors and it doesn't seem to work, read up on the default exclusion set in Directory-based Tasks, and see the defaultexcludes attribute below.

Parameters

Attribute Description Required
file The file to delete, specified as either the simple filename (if the file exists in the current base directory), a relative-path filename, or a full-path filename. At least one of the two, unless a <fileset> is specified.
dir The directory to delete, including all its files and subdirectories.
Note: dir is not used to specify a directory name for file; file and dir are independent of each other.
WARNING: Do not set dir to ".", "${basedir}", or the full-pathname equivalent unless you truly intend to recursively remove the entire contents of the current base directory (and the base directory itself, if different from the current working directory).
verbose Whether to show the name of each deleted file. No, default "false"
quiet If the specified file or directory does not exist, do not display a diagnostic message (unless Ant has been invoked with the ‑verbose or ‑debug switches) or modify the exit status to reflect an error. When set to "true", if a file or directory cannot be deleted, no error is reported. This setting emulates the -f option to the Unix rm command. Setting this to "true" implies setting failonerror to "false". No, default "false"
failonerror Controls whether an error (such as a failure to delete a file) stops the build or is merely reported to the screen. Only relevant if quiet is "false". No, default "true"
includeemptydirs Whether to delete empty directories when using filesets. No, default "false"
includes Deprecated. Use <fileset>. Comma- or space-separated list of patterns of files that must be deleted. All files are relative to the directory specified in dir. No
includesfile Deprecated. Use <fileset>. The name of a file. Each line of this file is taken to be an include pattern. No
excludes Deprecated. Use <fileset>. Comma- or space-separated list of patterns of files that must be excluded from the deletion list. All files are relative to the directory specified in dir. No files (except default excludes) are excluded when omitted. No
excludesfile Deprecated. Use <fileset>. The name of a file. Each line of this file is taken to be an exclude pattern No
defaultexcludes Deprecated. Use <fileset>. Whether to use default excludes. No, default "true"
deleteonexit Indicates whether to use File#deleteOnExit() if there is a failure to delete a file, this causes the jvm to attempt to delete the file when the jvm process is terminating. Since Ant 1.6.2 No, default "false".

Examples

  <delete file="/lib/ant.jar"/>

deletes the file /lib/ant.jar.

  <delete dir="lib"/>

deletes the lib directory, including all files and subdirectories of lib.

  <delete>
    <fileset dir="." includes="**/*.bak"/>

  </delete>

deletes all files with the extension .bak from the current directory and any subdirectories.

  <delete includeEmptyDirs="true">
    <fileset dir="build"/>

  </delete>

deletes all files and subdirectories of build, including build itself.

  <delete includeemptydirs="true">
    <fileset dir="build" includes="**/*"/>

  </delete>

deletes all files and subdirectories of build, without build itself.

Source: Apache Ant


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.