Hi folks, is there any Split() function in Java? The function should split up strings by a specified token and put each part in a string array. Thanks.
Printable View
Hi folks, is there any Split() function in Java? The function should split up strings by a specified token and put each part in a string array. Thanks.
Code:String toSplit = "Hello,World,!";
String split[] = toSplit.split(",");
for (int cnt = 0; cnt < split.length; cnt++)
{
System.out.println(split[cnt]);
}
You could also go with a StringTokenizer object.
:)
Oh nice, thanks both!