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 how to depart String by Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to depart String by "space"" Watch "how to depart String by "space"" New topic

how to depart String by "space"

marshal ma

Joined: May 31, 2004
Posts: 23
I have a String like "it is good", I know the String is made of three words(two space between three words), I want to turn it to three String, like this:

String data1 = it;
String data2 = is;
String data3 = good;

How to do that easily?

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

The String.split() method is a very easy way to do exactly what you want.

[Jess in Action][AskingGoodQuestions]
marshal ma

Joined: May 31, 2004
Posts: 23
Hi Ernest Friedman-Hill

Got it, I didn't know there is such a good method.

Thanks a lot,
Julien Grenier
Ranch Hand

Joined: Sep 01, 2005
Posts: 41
Lesson number one : Know your API
I agree. Here's the link:
subject: how to depart String by "space"
jQuery in Action, 3rd edition