Java URL Query Split splitQuery(String queryString)

Here you can find the source of splitQuery(String queryString)

Description

split Query

License

Apache License

Declaration

public static Map<String, String> splitQuery(String queryString) throws UnsupportedEncodingException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.LinkedHashMap;
import java.util.Map;

public class Main {
    public static Map<String, String> splitQuery(String queryString) throws UnsupportedEncodingException {
        Map<String, String> query_pairs = new LinkedHashMap<String, String>();
        String[] pairs = queryString.split("&");
        for (String pair : pairs) {
            int idx = pair.indexOf("=");
            query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"),
                    URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
        }//  w  w w .  ja  va  2s .  c  om
        return query_pairs;
    }
}

Related

  1. splitQuery(String query)
  2. splitQuery(String query)
  3. splitQuery(String url)
  4. splitQuery(URL url)
  5. splitQuery(URL url)