Apache Ant Token Filter

Token filter allows us to filter data from the file while copying. To filter, a token is used which must matched to @token@ set in filter task. Tasks uses @ as a token separator. To implement this feature, Apache Ant provides <filter> which uses token attribute.

This feature should be used with text file only.

Apache Ant Token Filter Attributes

AttributeDescriptionRequired
tokenIt is a token string without the separator chars (@).Yes
valueIt is a string that should be put to replace the token when the file is copied.Yes
filtersfileThe file from which the filters must be read. This file must be a formatted as a property file.Yes

Apache Ant Token Filter Example

The following code copy recursively all the files from the source directory into the destination directory by replacing all the repeatition of the string @name@ with rohan.

To read all property entries from the student_data.properties file and set these as filters.





Latest Courses