File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Splitting Strings" Watch "Splitting Strings" New topic

Splitting Strings

Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
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.
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

you could use a stringTokenizer. check out the API here:
[ 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.
I agree. Here's the link:
subject: Splitting Strings
jQuery in Action, 3rd edition