Home » Apache Ant Token Filters

Apache Ant Token Filters

by Online Tutorials Library

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 @[email protected] 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

Attribute Description Required
token It is a token string without the separator chars (@). Yes
value It is a string that should be put to replace the token when the file is copied. Yes
filtersfile The 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 @[email protected] with rohan.

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

You may also like