I've been developing an Android app for the past 4 Months now and came across the following regarding the split 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 !"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With