public static Map < String , String > getQueryParams ( String s ) throws MalformedURLException { Map < String , String > params = new HashMap < String , String > ( ) ; for ( String kv : s . split ( "&" ) ) { String [ ] parts = kv . split ( "=" ) ; if ( parts . length != 2 ) { throw new MalformedURLException ( ) ; } try { String k = URLDecoder . decode ( parts [ 0 ] , "UTF-8" ) ; String v = URLDecoder . decode ( parts [ 1 ] , "UTF-8" ) ; params . put ( k , v ) ; } catch ( UnsupportedEncodingException ex ) { throw new MalformedURLException ( ex . getMessage ( ) ) ; } } return params ; }
Get traditional query parameters as a Java map