我有以下字符串str =“one|two|third|four| Five”
我尝试使用 str1[]=str.split("\\|");
拆分它,但在调试时显示异常。
错误是处理异步线程队列时出现异常
。这是什么以及如何做到这一点?
最佳答案
试试这个,
String tempString="one|two|three|four|five";
String str1[]=tempString.split("\\|");
for(int i=0;i<str1.length;i++)
{
Log.i("Str1["+i+"]",str1[i]);
}
结果是,
Str1[0]: one
Str1[1]: two
Str1[2]: three
Str1[3]: four
Str1[4]: five
关于java - 分割字符串时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11575278/