@ SuppressWarnings ( "rawtypes" ) public static String toQueryString ( Map params , String encoding ) throws UnsupportedEncodingException { if ( encoding == null ) encoding = "UTF-8" ; StringBuilder queryString = new StringBuilder ( "?" ) ; for ( Iterator i = params . entrySet ( ) . iterator ( ) ; i . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) i . next ( ) ; boolean hasMore = i . hasNext ( ) ; boolean wasAppended = appendEntry ( entry , queryString , encoding , "" ) ; if ( hasMore && wasAppended ) queryString . append ( ' ' ) ; } return queryString . toString ( ) ; }
Converts the given params into a query string started with ?