com.hibegin.http.server.util.HttpQueryStringUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simplewebserver Show documentation
Show all versions of simplewebserver Show documentation
Simple, flexible, less dependent, more extended. Less memory footprint, can quickly build Web project.
Can quickly run embedded, Android devices
package com.hibegin.http.server.util;
import java.util.*;
public class HttpQueryStringUtils {
public static Map parseUrlEncodedStrToMap(String queryString) {
if (Objects.isNull(queryString) || queryString.isEmpty()) {
return new HashMap<>();
}
Map> tempParam = new HashMap<>();
String[] args = queryString.split("&");
for (String string : args) {
int idx = string.indexOf("=");
if (idx != -1) {
String key = string.substring(0, idx);
String value = string.substring(idx + 1);
if (tempParam.containsKey(key)) {
tempParam.get(key).add(value);
} else {
List paramValues = new ArrayList<>();
paramValues.add(value);
tempParam.put(key, paramValues);
}
}
}
Map paramMap = new HashMap<>();
for (Map.Entry> entry : tempParam.entrySet()) {
paramMap.put(entry.getKey(), entry.getValue().toArray(new String[0]));
}
return paramMap;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy