I would suggest having StringTokenizer return the delimiter [new
StringTokenizer(<str>,<delim>,true)], then use this to determine what field
you're in. Otherwise you could look into using StreamTokenizer with a
StringReader. The StreamTokenizer is a much more sophisticated parser.
On Wed, 19 Jul 2000, Lietz, Carol wrote:
> Sven,
>
> There have been a couple of options already tossed out. Here's yet another
> one. Rather than changing your application code, you could take the source
> for java.util.StringTokenizer and modify it to return what you want and
> rename it to represent your own version of StringTokenizer.
>
> Carol
>
> -----Original Message-----
> From: Harkishin Nachnani [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 17, 2000 1:34 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Empty string bug using String Tokenizer
>
>
> Thanks sven, but the string that I am parsing will always be something
> like "1,2,,4". How do I generate 4 strings out of this and make use of
> them in my servlet.
> Is there any other way to doing this ???
>
> > -----Original Message-----
> > From: Sven van 't Veer [SMTP:[EMAIL PROTECTED]]
> > Sent: Monday, July 17, 2000 2:18 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: Empty string bug using String Tokenizer
> >
> > Harkishin Nachnani wrote:
> > >
> > > I have a string : "1,2,,4"
> > > I am using String Tokenizer class with the delimiter ","
> > > I should get 4 strings : "1" "2" " " "4"
> > You probably would get this when you have "1,2, ,4" but probably not
> > with "1,2,,4" since there is no token to return.
> > > The 3rd String should be an empty string. But the String Tokenizer
> > class
> > > gives me only 3 strings without the empty string.
> > That's because nextElement should return null in the case of ,,
> >
> >
> > sven
> >
> >
> > --
> > ======================================================================
> > ================
> > Sven van 't Veer
> > http://www.cachoeiro.net
> > Java Developer
> > [EMAIL PROTECTED]
> > _/_
> > The answer / \
> > to the ultimate question nnn|.
> > .|nnn 42
> > =========================================U============================
> > ================
> >
> > ______________________________________________________________________
> > _____
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> > body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources:
> > http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html