public static String encodeForms ( Collection < ? extends Parameter < String > > queries , Charset charset ) { StringBuilder sb = new StringBuilder ( ) ; try { for ( Parameter < String > query : queries ) { sb . append ( URLEncoder . encode ( query . name ( ) , charset . name ( ) ) ) ; sb . append ( ' ' ) ; sb . append ( URLEncoder . encode ( query . value ( ) , charset . name ( ) ) ) ; sb . append ( ' ' ) ; } } catch ( UnsupportedEncodingException e ) { // should not happen throw new RequestsException ( e ) ; } if ( sb . length ( ) > 0 ) { sb . deleteCharAt ( sb . length ( ) - 1 ) ; } return sb . toString ( ) ; }
Encode multi form parameters