ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "DHARNA, AJAY [AG/1000]" <>
Subject RE: Using ant to parse text file
Date Thu, 22 Feb 2007 15:58:05 GMT
I have looked at the property task as well - but I will not be able to
change the file format.

I used the following target to get "Test2"

<target name="getGroupValue">
    <loadfile srcfile="${src.file}" property="text">
          <contains value="Test2"/>

Is there anyway to get back the line number where this is found - If I
can get back the line number - I could use the headfilter to get this
next line.

Thank you

Ajay Dharna

-----Original Message-----
From: Kevin Jackson [] 
Sent: Thursday, February 22, 2007 1:59 AM
To: Ant Users List
Subject: Re: Using ant to parse text file

> [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


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 and then load the values

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


To unsubscribe, e-mail:
For additional commands, e-mail:

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

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.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message