How to write to a file in Ant

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}
<echo/>

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.

Оцените статью
ASJAVA.COM
Добавить комментарий

Your email address will not be published. Required fields are marked *

*

code

  1. anon

    Here’s the right syntax

    The content to be written to myoutput.txt, the classpath is ${classpath}

    Ответить
    1. anon

      The content to be written to myoutput.txt, the classpath is ${classpath}

      Ответить
    2. admin автор

      What’s the difference on the two statements?

      Ответить
  2. anon

    The content to be written to myoutput.txt, the classpath is ${classpath}

    Ответить