You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Felix Dorner <FD...@zed.com> on 2009/04/08 10:52:32 UTC
Read a file line by line and do something for each line
Hey,
I'm trying to figure out a way how to read a text file line by line.
Then for each read line I'd like to invoke a macro with that line's contents as an argument. I can't find a better whay than using ant-contribs math+var tasks to count the number of lines read so far. With that I can use <headfilter> to just read the next line. Any other possibilities?
Thanks,
Felix
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
RE: Read a file line by line and do something for each line
Posted by Felix Dorner <FD...@zed.com>.
Hey Jan,
> <loadfile property="src" srcFile="..."/> <ac:for param="line"
> list="${src}" delimiter="${line.separator}">
> <sequential>
> <mymacro line="@{line}"/>
> </sequential>
> </ac:for>
Yes this works too, apart from my natural dislikes against for. :-)
I'll include a <fixcrlf> filter and meditate into happiness..:
Thanks,
Felix
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
AW: Read a file line by line and do something for each line
Posted by Ja...@rzf.fin-nrw.de.
>I'm trying to figure out a way how to read a text file line by line.
>Then for each read line I'd like to invoke a macro with that
>line's contents as an argument. I can't find a better whay
>than using ant-contribs math+var tasks to count the number of
>lines read so far. With that I can use <headfilter> to just
>read the next line. Any other possibilities?
not tested
<loadfile property="src" srcFile="..."/>
<ac:for param="line" list="${src}" delimiter="${line.separator}">
<sequential>
<mymacro line="@{line}"/>
</sequential>
</ac:for>
Jan
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org