This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Splitting Strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Splitting Strings" Watch "Splitting Strings" New topic
Author

Splitting Strings

Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
Hi,
Does anyone know how I can take a String and split it into 2 seperate strings? I have a name string and need it to be changed into a firstname string and second name string so the split should occur at the space.
Thanks
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11150
    
  16

you could use a stringTokenizer. check out the API here:
StringTokenizer
[ February 09, 2004: Message edited by: fred rosenberger ]

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Peyton McCullough
Ranch Hand

Joined: Feb 07, 2004
Posts: 31
The split() function will also work.
 
wood burning stoves
 
subject: Splitting Strings
 
Similar Threads
Parsing out names from String
Split string on a word not just a character
String Reading
Some String-like questions
splitting arrays