FileDocCategorySizeDatePackage
Rename.javaAPI DocApache Ant 1.702875Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.taskdefs

Rename

public class Rename extends org.apache.tools.ant.Task
Renames a file.
deprecated
The rename task is deprecated since Ant 1.2. Use move instead.
since
Ant 1.1

Fields Summary
private static final org.apache.tools.ant.util.FileUtils
FILE_UTILS
private File
src
private File
dest
private boolean
replace
Constructors Summary
Methods Summary
public voidexecute()
Renames the file src to dest

exception
org.apache.tools.ant.BuildException The exception is thrown, if the rename operation fails.

        log("DEPRECATED - The rename task is deprecated.  Use move instead.");

        if (dest == null) {
            throw new BuildException("dest attribute is required", getLocation());
        }

        if (src == null) {
            throw new BuildException("src attribute is required", getLocation());
        }

        if (!replace && dest.exists()) {
            throw new BuildException(dest + " already exists.");
        }

        try {
            FILE_UTILS.rename(src, dest);
        } catch (IOException e) {
            throw new BuildException("Unable to rename " + src + " to "
                + dest, e, getLocation());
        }
    
public voidsetDest(java.io.File dest)
Sets the new name of the file.

param
dest the new name of the file.

        this.dest = dest;
    
public voidsetReplace(java.lang.String replace)
Sets whether an existing file should be replaced.

param
replace on, if an existing file should be replaced.

        this.replace = Project.toBoolean(replace);
    
public voidsetSrc(java.io.File src)
Sets the file to be renamed.

param
src the file to rename



                     
        
        this.src = src;