Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import android.net.Uri;
import android.text.TextUtils;

import java.io.UnsupportedEncodingException;

import java.net.URLDecoder;

import java.util.HashMap;

public class Main {
    @Deprecated
    public static HashMap<String, String> parseDataGET(Uri uri) {
        String params = uri.getEncodedPath().substring(1);
        return splitParams(params);
    }

    @Deprecated
    public static HashMap<String, String> splitParams(String params) {
        if (TextUtils.isEmpty(params)) {
            return new HashMap<String, String>();
        }
        String[] kvs = params.split("&");
        HashMap<String, String> map = new HashMap<String, String>(kvs.length);
        for (String string : kvs) {
            String[] kv = string.split("=");
            if (kv.length == 2) {
                try {
                    kv[1] = URLDecoder.decode(kv[1], "utf-8");
                } catch (UnsupportedEncodingException e) {

                }
                map.put(kv[0], kv[1]);
            }
        }
        return map;
    }
}