public static String httpRequest ( String stringUrl , String method , Map < String , String > parameters , String input , String charset ) throws IOException { URL url = new URL ( stringUrl ) ; HttpURLConnection conn = ( HttpURLConnection ) url . openConnection ( ) ; conn . setDoOutput ( true ) ; conn . setRequestMethod ( method ) ; if ( parameters != null ) { for ( Entry < String , String > entry : parameters . entrySet ( ) ) { conn . addRequestProperty ( entry . getKey ( ) , entry . getValue ( ) ) ; } } if ( input != null ) { OutputStream output = null ; try { output = conn . getOutputStream ( ) ; output . write ( input . getBytes ( charset ) ) ; } finally { if ( output != null ) { output . close ( ) ; } } } return MyStreamUtils . readContent ( conn . getInputStream ( ) ) ; }
Execute a HTTP request