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

Reply via email to