Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 92308 invoked from network); 23 Nov 2009 10:23:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Nov 2009 10:23:34 -0000 Received: (qmail 9907 invoked by uid 500); 23 Nov 2009 10:23:33 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 9815 invoked by uid 500); 23 Nov 2009 10:23:32 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 9791 invoked by uid 99); 23 Nov 2009 10:23:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Nov 2009 10:23:31 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00 X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [209.85.219.224] (HELO mail-ew0-f224.google.com) (209.85.219.224) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Nov 2009 10:23:28 +0000 Received: by ewy24 with SMTP id 24so1965192ewy.6 for ; Mon, 23 Nov 2009 02:23:06 -0800 (PST) Received: by 10.216.86.204 with SMTP id w54mr1460312wee.54.1258971786642; Mon, 23 Nov 2009 02:23:06 -0800 (PST) Received: from ?172.20.5.20? ([135.196.6.178]) by mx.google.com with ESMTPS id t2sm9100624gve.9.2009.11.23.02.22.55 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 23 Nov 2009 02:23:06 -0800 (PST) Subject: Re: Parsing comma-separated string and getting handle to each token From: "Adam Leggett (UPCO)" To: Ant Users List In-Reply-To: <26474937.post@talk.nabble.com> References: <26474937.post@talk.nabble.com> Content-Type: text/plain Date: Mon, 23 Nov 2009 10:22:28 +0000 Message-Id: <1258971748.6678.8.camel@leggetta-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.24.3 Content-Transfer-Encoding: 7bit To solve your problem, i'd suggest a scripted approach using something like the or task. If using groovy for example, this would allow you to use similar Java code as in your suggestion and give you much more fine grained control over error handling etc e.g. if the data in the file is malformed for some reason or the file is missing. Thanks Adam On Mon, 2009-11-23 at 02:06 -0800, rohit15 wrote: > Hi gurus, > > Can you please help me resolve this seemingly simple requirement. > > I have a my.txt file like > localVariable1,propVariable11,propVariable12 > localVariable2,propVariable21,propVariable22 > localVariable3,propVariable31,propVariable32 > > > I need to parse this line by line and then process each line. While > processing each line, I need to execute separate logic on the 2nd and 3rd > variables of each line. > > I've been able to parse each line using the following code. However, I > haven't succeeded in getting handle to 2nd and 3rd variables by reference > [For e.g. in Java, I'd have iterated using stringtokenizer and referred as > stringtkr.token[1], or token[2] -something on those lines] > > > > > > Line param :: @{lineparam} > > > > > > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org