List of utility methods to do URL Query Split
Map | splitQuery(String query) split Query if (query == null || query.isEmpty()) { return new HashMap<>(); } else { String[] params = query.split("&"); Map<String, String> map = new HashMap<>(); for (String param : params) { String[] split = param.split("="); map.put(URLDecoder.decode(split[0], "UTF-8"), ... |
Multimap | splitQuery(String query) split Query Multimap<String, String> query_pairs = LinkedListMultimap.create(); String[] pairs = query.split("&"); for (String pair : pairs) { int idx = pair.indexOf("="); query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8")); return query_pairs; ... |
Map | splitQuery(String queryString) split Query Map<String, String> query_pairs = new LinkedHashMap<String, String>(); String[] pairs = queryString.split("&"); for (String pair : pairs) { int idx = pair.indexOf("="); query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8")); return query_pairs; ... |
Map | splitQuery(String url) split Query URL myURL = null; try { myURL = new URL(url); } catch (MalformedURLException e) { e.printStackTrace(); Map<String, String> query_pairs = new LinkedHashMap<String, String>(); String query = myURL.getQuery(); ... |
Map | splitQuery(URL url) split Query Map<String, String> queryPairs = new LinkedHashMap<String, String>(); String query = url.getQuery(); String[] pairs = query.split("&"); for (String pair : pairs) { int idx = pair.indexOf("="); String key = URLDecoder.decode(pair.substring(0, idx), "UTF-8"); if (queryPairs.get(key) == null) { queryPairs.put(key, URLDecoder.decode(pair.substring(idx + 1), "UTF-8")); ... |
Map | splitQuery(URL url) split Query final Map<String, List<String>> query_pairs = new LinkedHashMap<String, List<String>>(); final String[] pairs = url.getQuery().split("&"); for (String pair : pairs) { final int idx = pair.indexOf("="); final String key = idx > 0 ? URLDecoder.decode(pair.substring(0, idx), "UTF-8") : pair; if (!query_pairs.containsKey(key)) { query_pairs.put(key, new LinkedList<String>()); final String value = idx > 0 && pair.length() > idx + 1 ? URLDecoder.decode(pair.substring(idx + 1), "UTF-8") : null; query_pairs.get(key).add(value); return query_pairs; |