private String getPostData ( final ICommandLine cl ) throws Exception { // String encoded = ""; StringBuilder encoded = new StringBuilder ( ) ; String data = cl . getOptionValue ( "post" ) ; if ( data == null ) { return null ; } String [ ] values = data . split ( "&" ) ; for ( String value : values ) { String [ ] splitted = value . split ( "=" ) ; String key = splitted [ 0 ] ; String val = "" ; if ( splitted . length > 1 ) { val = splitted [ 1 ] ; } if ( encoded . length ( ) != 0 ) { encoded . append ( ' ' ) ; } encoded . append ( key ) . append ( ' ' ) . append ( URLEncoder . encode ( val , "UTF-8" ) ) ; // encoded += key + "=" + URLEncoder.encode(val, "UTF-8") + "&"; } // if (encoded.endsWith("&")) { // StringUtils.removeEnd(encoded, "&"); // } return encoded . toString ( ) ; }
Returns encoded post data .