Java URL Query Parse parseQueryString(String queryString)

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

Description

parse Query String

License

Apache License

Declaration

public static Map<String, List<String>> parseQueryString(String queryString) 

Method Source Code


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

import java.net.URI;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.toList;

public class Main {
    private static final Pattern PATTERN_AND = Pattern.compile("&");

    public static Map<String, List<String>> parseQueryString(URI uri) {
        return PATTERN_AND.splitAsStream(uri.getQuery()).map(s -> Arrays.copyOf(s.split("="), 2))
                .collect(Collectors.groupingBy(s -> s[0], Collectors.mapping(s -> s[1], toList())));
    }//from  w w  w  . ja  va  2s.co m

    public static Map<String, List<String>> parseQueryString(String queryString) {
        return PATTERN_AND.splitAsStream(queryString).map(s -> Arrays.copyOf(s.split("="), 2))
                .collect(Collectors.groupingBy(s -> s[0], Collectors.mapping(s -> s[1], toList())));
    }
}

Related

  1. parseQueryString(String q, String enc)
  2. parseQueryString(String query)
  3. parseQueryString(String query)
  4. parseQueryString(String query, boolean ignoreEmpty)
  5. parseQueryString(String queryString)
  6. parseQuerystring(String queryString)
  7. parseQueryString(String queryString, Map params)
  8. parseQueryStringEx(String queryString)
  9. parseURLQuery(String query)