开发者

Not able to split the Http Response

I am trying to split the response that I got from http posting. The response is a byte array.开发者_如何学Python

I am trying to split this as,

String venuesArray[] = text.toString().split("~~~");
for (String venueDetails:venuesArray) {         
       String arr2[] = venueDetails.split("^^^");
}

Here I am able to split the venuesArray without any problem, but same thing is not happening with venueDetails. It is not getting splitted.

Any answer for this?


The ^ character is a special character and needs to be escaped.

In Java, the backslash is also special, so you need an extra escape.

String arr2[] = venueDetails.split("\\^\\^\\^");


for (String venueDetails:venuesArray) {
    String arr2[] = venueDetails.split("\^\^\^");
}

should do it.


If venuesArray is splitting then, VenuesDetails should also split. Please check once VenuesArray has venues in it. If so,

Try using Regex :

for (String venueDetails:venuesArray) {
        String arr2[] = venueDetails.split("\\^^^");
}

Hope it helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜