Java URL Parameter Builder getURLParameters(URI uri)

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

Description

get URL Parameters

License

BSD License

Declaration

public static Map getURLParameters(URI uri) 

Method Source Code

//package com.java2s;
/*/*from  w w w .j av  a 2s  .  c o  m*/
 * Copyright (c) 2012. betterFORM Project - http://www.betterform.de
 * Licensed under the terms of BSD License
 */

import java.net.URI;

import java.util.HashMap;
import java.util.Map;

public class Main {
    public static Map getURLParameters(URI uri) {
        if (uri == null) {
            return null;
        }

        String query = uri.getQuery();
        if (query == null) {
            return null;
        }

        Map parameters = new HashMap();
        String[] pairs = query.split("&");
        String[] tokens;

        for (int index = 0; index < pairs.length; index++) {
            tokens = pairs[index].split("=");
            parameters.put(tokens[0], tokens.length > 1 ? tokens[1] : "");
        }

        return parameters;
    }
}

Related

  1. getUrlParameters(String url)
  2. getUrlParameters(String url)
  3. getUrlParameters(String url)
  4. getUrlParameters(String url)
  5. getUrlParameters(String url)
  6. map2String(Map params)
  7. mapToFormEncodedString(Map data)
  8. mapToFormString(Map map)
  9. mapToStr( Map map)