Here you can find the source of parseQuerystring(String queryString)
Parameter | Description |
---|---|
queryString | the string to parse (without the '?') |
public static Map<String, String> parseQuerystring(String queryString)
//package com.java2s; /**/* w w w .j av a2s . c o m*/ * Mule Google Api Commons * * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com * * The software in this package is published under the terms of the CPAL v1.0 * license, a copy of which has been included with this distribution in the * LICENSE.txt file. */ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.HashMap; import java.util.Map; public class Main { /** * Parse a querystring into a map of key/value pairs. * * @param queryString the string to parse (without the '?') * @return key/value pairs mapping to the items in the querystring */ public static Map<String, String> parseQuerystring(String queryString) { Map<String, String> map = new HashMap<String, String>(); if ((queryString == null) || (queryString.equals(""))) { return map; } String[] params = queryString.split("&"); for (String param : params) { try { String[] keyValuePair = param.split("=", 2); String name = URLDecoder.decode(keyValuePair[0], "UTF-8"); if (name == "") { continue; } String value = keyValuePair.length > 1 ? URLDecoder.decode( keyValuePair[1], "UTF-8") : ""; map.put(name, value); } catch (UnsupportedEncodingException e) { // ignore this parameter if it can't be decoded } } return map; } }