I need to split my String by spaces. For this I tried:
str = \"Hello I\'m your String\";
String[] splited = str.split(\" \");
But it doesn\
Since it's been a while since these answers were posted, here's another more current way to do what's asked:
List output = new ArrayList<>();
try (Scanner sc = new Scanner(inputString)) {
while (sc.hasNext()) output.add(sc.next());
}
Now you have a list of strings (which is arguably better than an array); if you do need an array, you can do output.toArray(new String[0]);