This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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

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: 11858

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Splitting Strings
It's not a secret anymore!