In java I have a method that recieves a string that looks like:
"Name ID CSVofInts"
It's purpose is to create a new object with the name, ID and then pass in the CSV as an int array.
How do you split such a string?
In java I have a method that recieves a string that looks like:
"Name ID CSVofInts"
It's purpose is to create a new object with the name, ID and then pass in the CSV as an int array.
How do you split such a string?
Try this:
String items [] = str.split(" ", 3);
String csv [] = items[2].split(",");
http://download.oracle.com/javase/1.5.0/docs/api/java/lang/String.html#split(java.lang.String)
Try the Java string split() function.
public String[] split(String regex)
The string "boo:and:foo", for example, yields the following results with these expressions:
Regex -> ":"
Result ->
{ "boo", "and", "foo" }
Returns an array of strings. :)