Chapter 12. FileUtils

The FileUtils task provides a number of useful file information functions, such as readability, writability, length, etc. Caution: this task does not follow the standard Ant convention of property immutability.

To use this task in your build files, include a task definition like this:


    <taskdef name="fileutil" classname="ise.antelope.tasks.FileUtilTask"/>
   

Table 12.1. FileUtil Task Attributes

AttributeDescriptionDefaultRequired
fileThe file or directory in question.NoneNo, but does nothing without a file.
propertyWhere to store the answer. Caution: this task will overwrite any existing property with this name.NoneNo

Operations as nested elements:

listfiles Create a list of files and/or directories.

Table 12.2. listfiles

AttributeDescriptionDefaultRequired
whatWhat to list, valid values are "files", "dirs", or "all".filesNo
separatorThe separator to use between individual items in the list of files., (comma)No
includepathIf true, include the path with the names in the list. If false, include only the names.trueNo

lastmodified Get the "last modified" date/timestamp of a file.

Table 12.3. lastmodified

AttributeDescriptionDefaultRequired
formatA format for the last modified timestamp. Must comply with the standards listed in java.text.SimpleDateFormat. No

These operations have no attributes:

Only one of the operations can be used at once.

Examples: See the Split for several examples.