Java. How can I split a string with multiple spaces on every nth space?

Viewed 3111

Here's a sample string which I intend to split into an array:

Hello My Name Is The Mighty Llama

The output should be:

Hello My
Name Is
The Mighty
Llama

The below splits on every space, how can I split on every other space?

String[] stringArray = string.split("\\s");
2 Answers
Related