Android Http Get httpGetRequestParseParams( String paramString)

Here you can find the source of httpGetRequestParseParams( String paramString)

Description

http Get Request Parse Params

License

Open Source License

Declaration

public static HashMap<String, String> httpGetRequestParseParams(
            String paramString) throws UnsupportedEncodingException 

Method Source Code

//package com.java2s;

import java.net.URLDecoder;

import java.util.HashMap;
import java.io.UnsupportedEncodingException;

public class Main {
    private static final String REQUEST_ENCODING_DEFAULT = "UTF-8";

    public static HashMap<String, String> httpGetRequestParseParams(
            String paramString) throws UnsupportedEncodingException {
        HashMap<String, String> result = new HashMap<String, String>();

        paramString = paramString.trim();

        if (paramString.length() > 0) {
            String[] params = paramString.replace('+', ' ').split("&");

            for (String param : params) {
                int index = param.indexOf('=');

                if (index >= 0) {
                    String name = param.substring(0, index);
                    String value = param.substring(index + 1);

                    result.put(URLDecoder.decode(name,
                            REQUEST_ENCODING_DEFAULT), URLDecoder.decode(
                            value, REQUEST_ENCODING_DEFAULT));
                } else {
                    result.put(URLDecoder.decode(param,
                            REQUEST_ENCODING_DEFAULT), "");
                }/*from w w w. j ava  2 s . com*/
            }
        }

        return result;
    }
}

Related

  1. executeHttpPost(String url, ArrayList postParameters)
  2. getHTTP(String... params)
  3. handleURLEncodedResponse(HttpResponse response)
  4. handleXMLResponse(HttpResponse response)
  5. getStringFromConnection( HttpURLConnection connection)
  6. formatHttpHeaders(Map headers)
  7. getStringResponseData(HttpResponse httpResponse)
  8. getHttpClient()
  9. maybeCreateHttpClient()