Apache Ant LoadFile Task

This task is used to load file into a property. It works on files and provides a srcFile attribute for ease. It uses default encoding current locale unless other one is specified.

It uses various attributes which are given below.

Apache Ant LoadFile Task Attributes

AttributeDescriptionRequired
srcFileIt is used to specify source file.Yes
propertyA property to where to save file.Yes
encodingTo set encoding of the file.No
failonerrorWhether to halt the build on failure or not.No
quietIt prevents to display a diagnostic message.No

Lets have some examples to understand it's functionalities.

Apache Ant LoadFile Task Example

The above code will produce the content of abc.txt file.

Specifying encoding while reading file.

Set failonerror to get error information





Latest Courses