开发者

Android split not working correctly

I've been developing an Android app for the past 4 Months now and came across the following regarding the spli开发者_C百科t function:

String [] arr;
SoapPrimitive result = (SoapPrimitive)envelope.getResponse();
arr = result.toString().trim().split("|");

The result variable is what I get after accessing my WebService, now this works perfectly. But, for some reason my split("|") method is not splitting at "|" but rather splitting at every single char in my result String. So my array looks like this:

arr[0] is "H", arr[1] is "e", etc......

I don't know why this is happening because I have used it before in the same project and it worked perfectly.

Thank you in advance


arr = result.toString().trim().split("\\|");

the param of String.split accept a regular expression.


Following code can be used for any pattern splitting.

String.split(Pattern.quote("any pattern you would like here !"));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜