This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Splitting a string to smaller strings. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Splitting a string to smaller strings." Watch "Splitting a string to smaller strings." New topic
Author

Splitting a string to smaller strings.

James Palmer
Ranch Hand

Joined: Mar 15, 2004
Posts: 36
Hello, i have a big string with lots of words in it and i want to find a way to split this string into separate words.This probably means that whenever the program finds a space it means that this is a new word and should make a new string for that one until it meets a space again.Particularly i want to use a tokenizer to do this.For example the string "I have a cat" should be split in 4 strings."I" "have" "a" "cat".Can anyone help?
john smith
Ranch Hand

Joined: Mar 04, 2004
Posts: 75
From the API javadoc:
Vicken Karaoghlanian
Ranch Hand

Joined: Jul 21, 2003
Posts: 522
You can learn more about the StringTokenizer here


- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. <br />- What truth? <br />- That there is no spoon!!!
David Peterson
author
Ranch Hand

Joined: Oct 14, 2001
Posts: 154
Alternatively use the split() method of String class.
 
jQuery in Action, 2nd edition
 
subject: Splitting a string to smaller strings.
 
Similar Threads
Splitting Strings
regular expression
splitting arrays
Object creation
change a string