public static Map<String, String> decodeKVMap(String keyValueString) {
    Map<String, String> keyValueMap = new HashMap<String, String>();
    /**
     * Only process if the KVString is not empty
     */
    if (keyValueString != null && !keyValueString.isEmpty()) {
      /**
       * If the keyValueString has been retrieved from a browser URI then strip
       * the leading '?' if present
       */
      if (keyValueString.startsWith("?")) {
        keyValueString = keyValueString.substring(1);
      }
      /**
       * Parse the URI string into key / value pairs. Decode each key value
       * pair, splitting the key/value pairs and populate the map with key and
       * (decoded) value pairs (This second-pass of decoding is important!)
       */
      String[] keyValuePairs = keyValueString.split("&");
      for (String keyValuePair : keyValuePairs) {
        try {
          String[] kv = decodeString(keyValuePair).split("=");
          keyValueMap.put(kv[0], decodeString(kv[1]));
        } catch (Exception ex) {
        }
      }
    }
    return keyValueMap;
  }