🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #8675

Re: Can you use a String as a delimeter in StringTokenizer

#8675
From: Alex Colic
Date: Tue, 06 Mar 2001 14:15
49 lines
2253 bytes
Hi, here is my complete code. In my previous example I used "!" as the
delimiter . I meant "Category!". I could not get it to parse correctly with
the latter delimiter so I tried the former.

        String text="Category!Commodity Code";
        String strCategoryPreAppend="Category!";
        StringTokenizer token=new StringTokenizer(text,
strCategoryPreAppend);

      System.out.println("Count: " + token.countTokens());
      while(token.hasMoreElements())
        {
         System.out.println("Token: " + token.nextElement());
        }

Count: 4
Token: mm
Token: di
Token:
Token: d

What I expect is two tokens: "Category" and "CommodityCode."

Thanks for the help.

Alex

"John McGrath [TeamB]" <ng-b@JPMcGrath.net> wrote in message
news:MPG.150e8591d5d31fe998a014@forums.borland.com...
> On Mon, 5 Mar 2001 16:30:58 -0500, Alex Colic wrote:
>
> > can  you use a String as a delimiter in StringTokenizer.
>
> Yes.
>
> > The above does not break the string down properly.
>
> That code looks fine to me.  What does it do, and what did you expect
> it to do?
>
> --
> Regards,
>
> John McGrath [TeamB]
>
> ---------------------------------------------------
> Before sending me e-mail, please read:
>     http://www.JPMcGrath.net/newsgroups/e-mail.html
>
Technical Details
Message-ID: <982rcl$n9q4@bornews.inprise.com>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsfeed01.tsnz.net!bornews.borland.com!not-for-mail
References: <9810gn$fl1@bornews.inprise.com> <MPG.150e8591d5d31fe998a014@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,22501d0a26c51927
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-03-06 06:33:23 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsfeed01.tsnz.net!bornews.borland.com!not-for-mail
From: "Alex Colic" <alex.colic@pop-ware.com>
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: Can you use a String as a delimeter in StringTokenizer
Date: Tue, 6 Mar 2001 09:15:53 -0500
Organization: Another Netscape Collabra Server User
Lines: 51
Message-ID: <982rcl$n9q4@bornews.inprise.com>
References: <9810gn$fl1@bornews.inprise.com> <MPG.150e8591d5d31fe998a014@forums.borland.com>
NNTP-Posting-Host: d150-29-218.home.cgocable.net
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200