[Solved] How to search a string of key/value pairs in Java


Use String.split:

String[] kvPairs = "key1=value1;key2=value2;key3=value3".split(";");

This will give you an array kvPairs that contains these elements:

key1=value1
key2=value2
key3=value3

Iterate over these and split them, too:

for(String kvPair: kvPairs) {
   String[] kv = kvPair.split("=");
   String key = kv[0];
   String value = kv[1];

   // Now do with key whatever you want with key and value...
   if(key.equals("specialkey")) {
       // Do something with value if the key is "specialvalue"...
   }
}

solved How to search a string of key/value pairs in Java