Q:

Wrong splitting string (split(" "))

I have some text, for example: 
String text = "I have some a good text".
String[] s = text.split(" ");

and I have such result:
s[0] - I have,
s[1] - some,
s[2] - a good,
s[3] - text

Why splitter don't split text, when between space (" ") 2 or 1 symbols ("I     have" and "a good"), and how to solve this problem?

A:

In java, the split method takes a regex as a parameter. As such, I'd recommend splitting by any white space: 
text.split("\\s");

That way, even if you use a different non-printable whitespace in the text, it will get split.
See http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html 

