### Question:
URLUtils { public static Map<String, String> splitQuery(URL url) throws UnsupportedEncodingException { Map<String, String> queryPairs = new LinkedHashMap<>(); String query = url.getQuery(); String[] pairs = query.split("&"); for (String pair : pairs) { int idx = pair.indexOf("="); queryPairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8")); } return queryPairs; }  static Map<String, String> splitQuery(URL url); static String toQueryString(Map<String, String> params);  }### Answer:
@Test public void canSplitQueryUrl() throws MalformedURLException, UnsupportedEncodingException { URL url = new URL("http: URLUtils URLUtils = new URLUtils(); Map<String, String> parameters = URLUtils.splitQuery(url); assertTrue(parameters.containsKey("key1")); assertEquals("value1", parameters.get("key1")); assertTrue(parameters.containsKey("key2")); assertEquals("value2", parameters.get("key2")); }