Lorem Ipsum Foo Bar
and you want to split it by whitespaces, you can't do
myString.split(" "); because the output would be
("Lorem", "Ipsum", " ", "Foo", "Bar")Obviously the desired output would be:
("Lorem", "Ipsum", "Foo", "Bar")To do that in java use:
myString.split("\\s+");