Android URL Parameter Get parserURIQuery(String queryText)

Here you can find the source of parserURIQuery(String queryText)

Description

parser URI Query

Declaration

public static HashMap<String, String> parserURIQuery(String queryText) 

Method Source Code

//package com.java2s;

import java.net.URLDecoder;

import java.util.HashMap;

public class Main {
    public static HashMap<String, String> parserURIQuery(String queryText) {
        HashMap<String, String> resultMap = new HashMap<String, String>();
        StringBuilder stringBuilder = new StringBuilder();
        String key = null;/*from  w  ww  .j av a 2 s.c o m*/
        for (int index = 0; index < queryText.length(); index++) {
            char token = queryText.charAt(index);
            switch (token) {
            case '=':
                key = stringBuilder.toString();
                stringBuilder.delete(0, stringBuilder.length());
                break;
            case '&':
                resultMap.put(key,
                        URLDecoder.decode(stringBuilder.toString()));
                key = null;
                stringBuilder.delete(0, stringBuilder.length());
                break;
            default:
                stringBuilder.append(token);
            }
        }
        if (stringBuilder.length() != 0 && key != null) {
            resultMap.put(key, URLDecoder.decode(stringBuilder.toString()));
        }
        return resultMap;
    }
}

Related

  1. paserParams(String url)
  2. getParamValue(String url, String param)
  3. getValueFromQueryString(String url, String key)
  4. getQueryUrl(final String url)
  5. queryComponent(String url)