String getQueryString ( Map < String , String > params ) { StringBuilder builder = new StringBuilder ( ) ; try { boolean first = true ; for ( Map . Entry < String , String > entry : params . entrySet ( ) ) { if ( first ) { first = false ; } else { builder . append ( "&" ) ; } builder . append ( URLEncoder . encode ( entry . getKey ( ) , "UTF-8" ) ) ; builder . append ( "=" ) ; builder . append ( URLEncoder . encode ( entry . getValue ( ) , "UTF-8" ) ) ; } } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( "Your Java version does not support UTF-8 encoding." ) ; } return builder . toString ( ) ; }
Returns the query string of a URL from a parameter list .