Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public final static Map<String, String> queryToMap(String post) {
        Map<String, String> ret = new HashMap<String, String>();
        if (post == null) {
            return ret;
        }
        String[] fields = post.split("\\&");
        for (int i = 0; i < fields.length; i++) {
            String kv = fields[i];
            int idx = kv.indexOf('=');
            if (idx > 0) {
                ret.put(kv.substring(0, idx), kv.substring(idx + 1));
            }
        }
        return ret;
    }
}