android - ArrayIndexOutOfBoundsException at splitting string -
in android app have string value type yo_2014_rojo
. need split string in 3 parts: part1 ="yo"
part2="2014"
, part3="rojo"
.
i trying follows:
string s[] = dato_seleccionado.split("_"); string s1 = s[0]; string s2 = s[1]; string s3 = s[2];
but app crashes exception: arrayindexoutofboundsexception
.
any welcome.
try this...
string str = "yo_2014_rojo"; stringtokenizer token = new stringtokenizer(str , "_"); string part1 = token.nexttoken(); //yo string part2 = token.nexttoken(); //2014 string part3 = token.nexttoken(); //rojo
Comments
Post a Comment