我目前正面临该str.split()
功能的一个奇怪问题。首先这是我的代码:
String[] seperated = content.split("<div id=\"results\" style=\"width: 175px; \">");
Log.d("seperated length", "" + seperated.length);
if(seperated.length>1){
Log.d("sep1 t2.", seperated[1]);
String[] sep2 = seperated[1].split("<div id=\"map\" ");
Log.d("sep2 t1", sep2[0]);
String[] sep3 = sep2[0].split("<div class=\"resultLine\">");
result = new String[sep3.length];
for(int i=1; i<sep3.length; i++){
String[] temp = sep3[i].split("class=\"icon1\">");
String[] temp2 = temp[1].split("<br>");
String[] temp3 = temp2[1].split("<br");
String[] temp4 = temp3[0].split("</a>");
result[i-1] = temp2[0] + " " +temp4[0];
Log.d("places", result[i-1]);
}
handler.sendEmptyMessage(0);
} else {
handler.sendEmptyMessage(1);
}
在模拟器上生成结果数组没有问题,但在设备上第一次拆分失败,没有错误或任何东西。字符串内容与模拟器上的相同。