Oops. Didn't mean to hit send.
For a very long string you may get a StackOverFlowError as a result of the
recursion. In this case you may be better off writing your own iterator that
parses over the string.
Justy
----- Original Message -----
From: "horwat" <[EMAIL PROTECTED]>
To: "A mailing list about Java Server Pages specification and reference"
<[EMAIL PROTECTED]>
Sent: Friday, October 26, 2001 1:16 PM
Subject: Re: Re: Strings
> One thing to watch out for with the StringTokenizer class is that it is
> recursive. For a very long string you may get a
>
> ----- Original Message -----
> From: "Jan Aren�" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, October 26, 2001 6:47 AM
> Subject: Re: Strings
>
>
> > Use a string tokenizer
> >
> > this code takes all 30 (if there is 30) words of a long string and
return
> > them as a single string... If there are less then 30 it returns all
until
> > the end of the string
> >
> > StringTokenizer st = new StringTokenizer(YourString, " ");
> > int i = 0;
> > String returnString = new String("");
> > while(st.hasMoreTokens() && i < 30)
> > {
> > returnString = returnString.concat(st.nextToken());
> > i++;
> > }
> >
> > return returnString;
> >
> >
> > // Jan arenl
> > -----Ursprungligt meddelande-----
> > Fr�n: A mailing list about Java Server Pages specification and reference
> > [mailto:[EMAIL PROTECTED]]F�r Daniel Jaffa
> > Skickat: den 26 oktober 2001 15:35
> > Till: [EMAIL PROTECTED]
> > �mne: Re: Strings
> >
> >
> > what does the string look like
> >
> > Daniel Jaffa
> > Computer GOD who Created the Stars and Moon
> > "If you are not happy, I am not happy"
> >
> >
> >
> > _________________________________________________________________
> > Get your FREE download of MSN Explorer at
http://explorer.msn.com/intl.asp
> >
> >
>
===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> > DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://archives.java.sun.com/jsp-interest.html
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.jsp
> > http://www.jguru.com/faq/index.jsp
> > http://www.jspinsider.com
> >
> >
>
===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://archives.java.sun.com/jsp-interest.html
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.jsp
> > http://www.jguru.com/faq/index.jsp
> > http://www.jspinsider.com
> >
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com