Reputation: 133
My string: result = order=7781&state=1&value=&add=114GH;
I want to get values:
String order = "7781";
String state = "1";
String value = "";
String add = "114GH";
Please help me to solve this problem! Thanks!
I have done till here, but its not working.
String[] resDetails = result.split("&");
for(String pair : resDetails)
{
String[] entry = pair.split("=");
map.put(entry[0].trim(), entry[1].trim());
}
Its giving error because value
is empty
Upvotes: 0
Views: 2366
Reputation: 159135
Change split("=")
to split("=", -1)
, so trailing empty strings will not be discarded.
Upvotes: 1