I’m currently using ant to remove lines from a file if the line matches any of a list of email addresses, and output a new file without these email addresses as follows:
<copy file="src/emaillist.tmp2" tofile="src/emaillist.txt">
<filterchain>
<linecontains negate="true"><contains value="paultaylor@hotmail.com"/>
</linecontains>
<linecontains negate="true"><contains value="paultaylor2@hotmail.com"/>
</linecontains>
........
........
</filterchain>
</copy>
But I already have a file containing a list of the invalid email addresses (invalidemail.txt) I want to remove, so I want my ant file to read the list of invalid email addresses from this file rather than having to add a element for each email I don’t want. Cannot work out how to do this.
Ant has some useful resource list processing tasks. Here’s a ‘prototype’ solution.
Load the input and exclusion lists to two resource collections, tokenized by default on line breaks.
Do some set arithmetic to produce a resource list of clean emails:
Here’s some diagnostics that may be useful:
Use the
pathconverttask to reformat the clean list into one entry per line:Finally, output to a file: