Java URI Parse parseQueryString(URI uri)

Here you can find the source of parseQueryString(URI uri)

Description

parse Query String

License

Apache License

Declaration

public static Map<String, String> parseQueryString(URI uri) 

Method Source Code


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

import java.net.URI;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static Map<String, String> parseQueryString(URI uri) {
        Map<String, String> queryParams = new HashMap<String, String>();

        String query = uri.getQuery();

        if (query == null || query.isEmpty())
            return queryParams;

        String[] parts = query.split("&");

        for (String part : parts) {
            String[] subParts = part.split("=");
            if (subParts.length == 1) {
                queryParams.put(subParts[0], "");
            } else if (subParts.length == 2) {
                queryParams.put(subParts[0], subParts[1]);
            }/*from   ww w  .j  ava  2  s.  c  om*/
        }

        return queryParams;
    }
}

Related

  1. parseQuery(String uri)
  2. parseQuery(URI aURI, boolean shouldDecode)
  3. parseQuery(URI uri)
  4. parseQuery(URI uri)
  5. parseQueryString(final URI uri, final M queryParams)
  6. parseQueryString(URI uri, M queryParams)
  7. parseRegionName(URI endpoint)
  8. parseRegionName(URI endpoint)
  9. parseRegionName(URI endpoint)