Public Class AA {public static void main (string [] ARGs) {// create httpclient instance httpclient = new defaulthttpclient (); // create a get Method Instance httppost = new httppost ("http: // localhost: 8080/SSO/modify. action "); List <namevaluepair> nvps = new arraylist <namevaluepair> (); // submit two parameters and values nvps. add (New basicnamevaluepair ("data", "wwwq"); // set form submission encoding to UTF-8 try {httppost. setentity (New urlencode Dformentity (nvps, HTTP. utf_8); httpresponse response = httpclient.exe cute (httppost); httpentity entity = response. getentity (); If (entity! = NULL) {inputstream instreams = entity. getcontent (); string STR = convertstreamtostring (instreams); system. out. println ("do something"); system. out. println (STR); // do not need the rest} catch (exception e) {e. printstacktrace ();} finally {httppost. abort () ;}} public static string convertstreamtostring (inputstream is) {bufferedreader reader = new bufferedreader (New inputstreamreader (is); Str Ingbuilder sb = new stringbuilder (); string line = NULL; try {While (line = reader. Readline ())! = NULL) {sb. append (LINE + "\ n") ;}} catch (ioexception e) {e. printstacktrace ();} finally {try {is. close ();} catch (ioexception e) {e. printstacktrace () ;}} return sb. tostring ();}}
Httpclient --------- demo