fosho fosho - 2 years ago 66
Java Question

Split string into individual words Java

I would like to know how to split up a large string into a series of smaller strings or words.
For example:

I want to walk my dog.

I want to have a string:
another string:
, etc.

How would I do this?

Answer Source

Use split() method


String s = "I want to walk my dog";

 String[] arr = s.split(" ");    

 for ( String ss : arr) {

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download