To write the text message to a file in ant, you can use ant target echo, it provides the way to directly append to an existing file or write to the new file.

The below target demostrates how to write the string to a file in ant script

<echo file="myoutput.txt" append="true"/>
   The content to be written to myoutput.txt, the classpath is ${classpath}

If the file myoutput.txt already exists, ant will append the content to this file. If it does not, Ant will create a new one and write the content into it.