How to get values from string in java?

448
January 14, 2017, at 4:44 PM

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

Answer 1

Change split("=") to split("=", -1), so trailing empty strings will not be discarded.

Rent Charter Buses Company
READ ALSO
My Tomcat always need restart when too many user access app

My Tomcat always need restart when too many user access app

I have an java application that run on tomcat and access sql server databasethat have 100-200 user access this application daily

380
Compress (change resolution) NV21 image in Android

Compress (change resolution) NV21 image in Android

In the onPreviewFrame callback we can get the NV21 format imageNow before processing these data, I want to decrease the resolution the image first

594
How can I release a MediaPlayer after it is done playing if that MediaPlayer is continuing to be started?

How can I release a MediaPlayer after it is done playing if that MediaPlayer is continuing to be started?

Sound quits working in my game after a little bit because I'm not releasing my MediaPlayer after it is done playingHow can I release it if I continue to start that MediaPlayer as the game continues to be played? I run into an issue of trying to release...

298