learn_allot
learn_allot

Reputation: 21

ANT FilterChains and FilterReaders

I have a file depends.txt containing 2015001, 2015002, 2015003. I created an ANT target that have the following code. I tried searching on how to use the stringtokenizer attribute but the descriptions are vague. I would like to run the target and get 2015001 2015002 2015003 All the help are greatly appreciated. Thanks.

 `<loadfile srcFile="depends.txt" property="depends"/>
     <filterchain>
         <tokenfilter>
              <stringtokenizer delims="," />
         </tokenfilter>
   </filterchain>`

Upvotes: 1

Views: 233

Answers (1)

user4524982
user4524982

Reputation:

Ant's filterreaders can modify the input read by Ant and the tokenfilter is one of them. The tokenfilter doesn't do anything by itself but rather coordinates two different actors - a tokenizer and a filter.

The filter is the thing that performs the real action and the tokenizer is responsible for feeding the filter with chunks of text it works on. The separation of tokenizer and filters allows the same algorithm - say uniq - to be applied to either words or lines depending on the tokenizer.

In your example you only specify a tokenizer but no filter so the output is the same as the input. IIUC you only want to strip the comma characters, in that case

<loadfile srcFile="depends.txt" property="depends">
  <filterchain>
    <deletecharacters chars=","/>
  </filterchain>
</loadfile>

should do the trick.

Upvotes: 1

Related Questions