private static String buildUrlWithQueryString ( String url , Map < String , String > queryParas ) { if ( queryParas == null || queryParas . isEmpty ( ) ) return url ; StringBuilder sb = new StringBuilder ( url ) ; boolean isFirst ; if ( ! url . contains ( "?" ) ) { isFirst = true ; sb . append ( "?" ) ; } else { isFirst = false ; } for ( Entry < String , String > entry : queryParas . entrySet ( ) ) { if ( isFirst ) isFirst = false ; else sb . append ( "&" ) ; String key = entry . getKey ( ) ; String value = entry . getValue ( ) ; if ( StrKit . notBlank ( value ) ) try { value = URLEncoder . encode ( value , CHARSET ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } sb . append ( key ) . append ( "=" ) . append ( value ) ; } return sb . toString ( ) ; }
Build queryString of the url