Top Description Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class TempFile

extends Task
Class Inheritance
Imports
java.io.File, org.apache.tools.ant.BuildException, .Task, org.apache.tools.ant.util.FileUtils

This task sets a property to the name of a temporary file. Unlike File#createTempFile, this task does not (by default) actually create the temporary file, but it does guarantee that the file did not exist when the task was executed.

Examples

<tempfile property="temp.file" />
create a temporary file
<tempfile property="temp.file" suffix=".xml" />
create a temporary file with the .xml suffix.
<tempfile property="temp.file" destDir="build"/>
create a temp file in the build subdir
Since
Ant 1.5

Field Summary

Modifier and TypeField and Description
private boolean
createFile

createFile flag

private boolean
deleteOnExit

deleteOnExit flag

private File
destDir

Directory to create the file in. Can be null.

private static final FileUtils
private String
prefix

Prefix for the file.

private String
property

Name of property to set.

private String
suffix

Suffix for the file.

Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
execute()

Overrides org.apache.tools.ant.Task.execute.

Creates the temporary file.
public boolean

Returns:

the createFile flag.
isCreateFile
()

Learn whether createFile flag is set for this tempfile task.

public boolean

Returns:

boolean deleteOnExit flag.
isDeleteOnExit
()

Learn whether deleteOnExit is set for this tempfile task.

public void
setCreateFile(boolean
boolean flag.
createFile
)

If set the file is actually created, if not just a name is created.

public void
setDeleteOnExit(boolean
boolean flag.
deleteOnExit
)

Set whether the tempfile created by this task should be set for deletion on normal VM exit.

public void
setDestDir(File
The new destDir value
destDir
)

Sets the destination directory.

public void
setPrefix(String
string to prepend to generated string
prefix
)

Sets the optional prefix string for the temp file.

public void
setProperty(String
The property to set
property
)

Sets the property you wish to assign the temporary file to.

public void
setSuffix(String
suffix including any ".", e.g ".xml"
suffix
)

Sets the optional suffix string for the temp file.

Inherited from org.apache.tools.ant.Task:
bindToOwnergetOwningTargetgetRuntimeConfigurableWrappergetTaskNamegetTaskTypegetWrapperhandleErrorFlushhandleErrorOutputhandleFlushhandleInputhandleOutputinitisInvalidloglogloglogmaybeConfigureperformreconfiguresetOwningTargetsetRuntimeConfigurableWrappersetTaskNamesetTaskType

Field Detail

createFileback to summary
private boolean createFile

createFile flag

deleteOnExitback to summary
private boolean deleteOnExit

deleteOnExit flag

destDirback to summary
private File destDir

Directory to create the file in. Can be null.

FILE_UTILSback to summary
private static final FileUtils FILE_UTILS
prefixback to summary
private String prefix

Prefix for the file.

propertyback to summary
private String property

Name of property to set.

suffixback to summary
private String suffix

Suffix for the file.

Constructor Detail

TempFileback to summary
public TempFile()

Method Detail

executeback to summary
public void execute() throws BuildException

Overrides org.apache.tools.ant.Task.execute.

Creates the temporary file.

Annotations
@Override
Exceptions
BuildException:
if something goes wrong with the build
isCreateFileback to summary
public boolean isCreateFile()

Learn whether createFile flag is set for this tempfile task.

Returns:boolean

the createFile flag.

isDeleteOnExitback to summary
public boolean isDeleteOnExit()

Learn whether deleteOnExit is set for this tempfile task.

Returns:boolean

boolean deleteOnExit flag.

setCreateFileback to summary
public void setCreateFile(boolean createFile)

If set the file is actually created, if not just a name is created.

Parameters
createFile:boolean

boolean flag.

setDeleteOnExitback to summary
public void setDeleteOnExit(boolean deleteOnExit)

Set whether the tempfile created by this task should be set for deletion on normal VM exit.

Parameters
deleteOnExit:boolean

boolean flag.

setDestDirback to summary
public void setDestDir(File destDir)

Sets the destination directory. If not set, the basedir directory is used instead.

Parameters
destDir:File

The new destDir value

setPrefixback to summary
public void setPrefix(String prefix)

Sets the optional prefix string for the temp file.

Parameters
prefix:String

string to prepend to generated string

setPropertyback to summary
public void setProperty(String property)

Sets the property you wish to assign the temporary file to.

Parameters
property:String

The property to set

setSuffixback to summary
public void setSuffix(String suffix)

Sets the optional suffix string for the temp file.

Parameters
suffix:String

suffix including any ".", e.g ".xml"