new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
DefaultHttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(
"www.baidu.com");
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("key", value));
parameters.add(new BasicNameValuePair("key", value));
UrlEncodedFormEntity entity;
try {
entity = new UrlEncodedFormEntity(parameters, "utf-8");
httpPost.setEntity(entity);
HttpResponse response = client.execute(httpPost);
HttpEntity resultEntity = response.getEntity();
String body = EntityUtils.toString(resultEntity);
System.out.println(body)
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("---UnsupportedEncodingException--");
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("---IOException--");
}
}
}).start();
@Override
public void run() {
// TODO Auto-generated method stub
DefaultHttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(
"www.baidu.com");
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("key", value));
parameters.add(new BasicNameValuePair("key", value));
UrlEncodedFormEntity entity;
try {
entity = new UrlEncodedFormEntity(parameters, "utf-8");
httpPost.setEntity(entity);
HttpResponse response = client.execute(httpPost);
HttpEntity resultEntity = response.getEntity();
String body = EntityUtils.toString(resultEntity);
System.out.println(body)
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("---UnsupportedEncodingException--");
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("---IOException--");
}
}
}).start();