Java Utililty Methods URL Query Parse

List of utility methods to do URL Query Parse

Description

The list of methods to do URL Query Parse are organized into topic(s).

Method

Mapparse(String query, String encoding)
parse
Map<String, String> result = new HashMap<String, String>();
Scanner scanner = new Scanner(query);
scanner.useDelimiter(PARAMETER_SEPARATOR);
while (scanner.hasNext()) {
    String[] nameValue = scanner.next().split(NAME_VALUE_SEPARATOR);
    if (nameValue.length <= 0 || nameValue.length > 2) {
        continue;
    String name = decode(nameValue[0], encoding);
    String value = null;
    if (nameValue.length == 2) {
        value = decode(nameValue[1], encoding);
    result.put(name, value);
return result;
PropertiesparseInstructions(final String query)
Parses bnd instructions out of an url query string.
final Properties instructions = new Properties();
if (query != null) {
    try {
        final String segments[] = query.split("&");
        for (String segment : segments) {
            if (segment.trim().length() > 0) {
                final Matcher matcher = INSTRUCTIONS_PATTERN.matcher(segment);
                if (matcher.matches()) {
...
MapparseParameters(Optional queryString)
parse Parameters
Map<String, String[]> parameters = new HashMap<>();
if (!queryString.isPresent()) {
    return parameters;
final String[] parametersParts = queryString.get().split("&");
for (String parametersPart : parametersParts) {
    String[] parameterParts = parametersPart.split("=");
    if (parameterParts.length < 2) {
...
MapparseParameters(String query)
parse Parameters
Map<String, String> params = new HashMap<>();
StringTokenizer st = new StringTokenizer(query, "&");
while (st.hasMoreTokens()) {
    String token = st.nextToken();
    String[] keyValuePair = token.split("=");
    String key = URLDecoder.decode(keyValuePair[0], "UTF-8");
    String value = URLDecoder.decode(keyValuePair[1], "UTF-8");
    params.put(key, value);
...
Map>parseQuery(String query)
parse Query
Map<String, List<String>> params = new HashMap<String, List<String>>();
query = URLDecoder.decode(query, "UTF-8");
for (String param : query.split("&")) {
    String pair[] = param.split("=");
    String key = URLDecoder.decode(pair[0], "UTF-8");
    String value = "";
    if (pair.length > 1) {
        value = URLDecoder.decode(pair[1], "UTF-8");
...
MapparseQuery(String query)
Parsers the query string of the URI into a map of key-value pairs
Map<String, String> answer = new HashMap<String, String>();
if (query != null) {
    StringTokenizer iter = new StringTokenizer(query, "&");
    while (iter.hasMoreTokens()) {
        String pair = iter.nextToken();
        addKeyValuePair(answer, pair);
return answer;
HashtableparseQuery(String query)
Utility method to parse the query part of a URL into parameters.
String[][] params = new String[200][2];
Hashtable<String, String> parameters = new Hashtable<String, String>();
String temp = "";
boolean ampflag = true;
boolean poundflag = false;
int arrcount = 0;
if (query != null) {
    for (int i = 0; i < query.length(); i++) {
...
MapparseQuery(String query)
parse Query
Map<String, String> map = new HashMap<String, String>();
String[] entries = query.split("&");
for (String entry : entries) {
    String[] sides = entry.split("=");
    if (sides.length != 2) {
        throw new IOException("Invalid Query String");
    String key = URLDecoder.decode(sides[0], "UTF-8");
...
MapparseQuery(String query)
Extract and decode query parameters from an encoded query string
if (query == null || query.isEmpty())
    return Collections.emptyMap();
Map<String, String> result = new HashMap<String, String>();
int top = query.length();
int start = 0;
for (int idx = 0; idx < top; ++idx) {
    char c = query.charAt(idx);
    if (c == '&') {
...
MapparseQuery(String queryString)
Get properties from a URI query string.
if (queryString != null && !queryString.isEmpty()) {
    Map<String, String> rc = new HashMap<String, String>();
    String[] parameters = queryString.split("&");
    for (int i = 0; i < parameters.length; i++) {
        int p = parameters[i].indexOf("=");
        if (p >= 0) {
            String name = URLDecoder.decode(parameters[i].substring(0, p), "UTF-8");
            String value = URLDecoder.decode(parameters[i].substring(p + 1), "UTF-8");
...