Java Utililty Methods URL Query Parse

List of utility methods to do URL Query Parse

Description

The list of methods to do URL Query Parse are organized into topic(s).

Method

MapparseQueryParameters(String query)
parse Query Parameters
HashMap<String, String> values = new HashMap<String, String>();
parseQueryParameters(query, false, values);
return values;
MapparseQueryParameters(String queryString, String encoding)
Parses the parameters from the given url query string.
Map<String, String> parameters = new LinkedHashMap<String, String>();
if (queryString != null) {
    if (queryString.startsWith(QUERY_STRING_SEPARATOR)) {
        queryString = queryString.substring(1);
    Scanner scanner = new Scanner(queryString);
    scanner.useDelimiter(PARAMETER_SEPARATOR);
    while (scanner.hasNext()) {
...
Map>parseQueryString(final String newQueryString, final String encoding)
Parses a query string into a map
Map<String, Deque<String>> newQueryParameters = new LinkedHashMap<>();
int startPos = 0;
int equalPos = -1;
boolean needsDecode = false;
for (int i = 0; i < newQueryString.length(); ++i) {
    char c = newQueryString.charAt(i);
    if (c == '=' && equalPos == -1) {
        equalPos = i;
...
MapparseQueryString(String input)
parse Query String
try {
    Map<String, String> rv = new HashMap<String, String>();
    String[] parts = input.split("&");
    for (String part : parts) {
        String[] pair = part.split("=", 2);
        if (pair.length != 2)
            continue;
        String name = URLDecoder.decode(pair[0], "UTF-8");
...
MapparseQueryString(String path)
Parses the parameters in the path query string.
int index = path.indexOf('?');
if (index == -1) {
    return Collections.EMPTY_MAP;
String queryString = path.substring(index + 1);
StringTokenizer st = new StringTokenizer(queryString, "&");
Map<String, Object> result = new HashMap<String, Object>();
while (st.hasMoreTokens()) {
...
MapparseQueryString(String path)
Parses the parameters in the path query string.
int index = path.indexOf('?');
if (index == -1) {
    return Collections.EMPTY_MAP;
String queryString = path.substring(index + 1);
StringTokenizer st = new StringTokenizer(queryString, "&");
Map<String, String> result = new HashMap<String, String>();
while (st.hasMoreTokens()) {
...
MapparseQueryString(String q, String enc)
parse Query String
String[] params = q.split("&");
Map results = new Hashtable(params.length);
for (int i = 0; i < params.length; i++) {
    String[] kv = params[i].split("=", 2);
    results.put(URLDecoder.decode(kv[0], enc), kv.length > 1 ? URLDecoder.decode(kv[1], enc) : "");
return results;
MapparseQueryString(String query)
Parse the given query string into a Map.
Map<String, String> ret = new LinkedHashMap<String, String>();
for (String entry : query.split("&")) {
    String[] parts = entry.split("=", 2);
    String key, value;
    try {
        key = URLDecoder.decode(parts[0], "utf-8");
        if (parts.length == 1) {
            value = null;
...
MapparseQueryString(String query)
Parses the given query string, and returns a map of the query parameters.
Map<String, String> queryMap = new HashMap<>();
if (query == null || query.isEmpty()) {
    return queryMap;
String[] entries = query.split(String.valueOf(QUERY_SEPARATOR));
try {
    for (String entry : entries) {
        String[] parts = entry.split(String.valueOf(QUERY_KEY_VALUE_SEPARATOR));
...
MapparseQueryString(String query, boolean ignoreEmpty)
Parses a query string into a parameter map, decoding values as needed.
Map<String, String> result = new HashMap<String, String>();
if ((query == null) || (query.length() == 0))
    return result;
if (query.charAt(0) == '?')
    query = query.substring(1);
if (query.length() == 0)
    return result;
for (String param : query.split("&")) {
...