public static String queryString ( Map < String , Object > values ) { StringBuilder sbuf = new StringBuilder ( ) ; String separator = "" ; for ( Map . Entry < String , Object > entry : values . entrySet ( ) ) { Object entryValue = entry . getValue ( ) ; if ( entryValue instanceof Object [ ] ) { for ( Object value : ( Object [ ] ) entryValue ) { appendParam ( sbuf , separator , entry . getKey ( ) , value ) ; separator = "&" ; } } else if ( entryValue instanceof Iterable ) { for ( Object multiValue : ( Iterable ) entryValue ) { appendParam ( sbuf , separator , entry . getKey ( ) , multiValue ) ; separator = "&" ; } } else { appendParam ( sbuf , separator , entry . getKey ( ) , entryValue ) ; separator = "&" ; } } return sbuf . toString ( ) ; }
Convert a Map to a query string .