You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "DHARNA, AJAY [AG/1000]" <aj...@monsanto.com> on 2007/02/22 07:03:37 UTC

Using ant to parse text file

Hi all 

I am using Ant 1.6.5 - I would like to parse a text file that would contain
the following information: 

[Sample.txt] 
Test1 
Group=red 

Test2 
Group=blue 

Test3 
Group=green 

Example:- If I was to provide the value "Test2", I would like the Ant to
search for "Test2" in the file, and return the value "blue". If I provide
the value - "Test3", it should return the value "green"

Please let me know if there is any simple way of doing this using Ant. 

Thank you 

Ajay Dharna 


---------------------------------------------------------------------------------------------------------
This e-mail message may contain privileged and/or confidential information, and is intended to be received only by persons entitled to receive such information. If you have received this e-mail in error, please notify the sender immediately. Please delete it and all attachments from any servers, hard drives or any other media. Other use of this e-mail by you is strictly prohibited.


All e-mails and attachments sent and received are subject to monitoring, reading and archival by Monsanto. The recipient of this e-mail is solely responsible for checking for the presence of "Viruses" or other "Malware". Monsanto accepts no liability for any damage caused by any such code transmitted by or accompanying this e-mail or any attachment.
---------------------------------------------------------------------------------------------------------


Re: Using ant to parse text file

Posted by Kevin Jackson <fo...@gmail.com>.
> [Sample.txt]
> Test1
> Group=red
>
> Test2
> Group=blue
>
> Test3
> Group=green
>
> Example:- If I was to provide the value "Test2", I would like the Ant to
> search for "Test2" in the file, and return the value "blue". If I provide
> the value - "Test3", it should return the value "green"
>
> Please let me know if there is any simple way of doing this using Ant.

Given that you don't seem to have any more data for each of the Tests
- why don't you just do

Test1=red

then you can use Ant's property task

Even if you are going to group things together you can still use
properties just separate the properties into separate files and then
when you provide Test2, Ant can then lookup the appropraitely names
Test2.properties and then load the values

Unless you want to do something else, I think you want the properties task

Kev

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org