Code example for HttpPost

Methods: setEntityaddHeadergetParams

0
	 *             Network error 
	 */ 
	public HttpEntity postURL(String url, NameValuePair[] params, String referer,boolean useTorProxy)
			throws IOException { 
 
		HttpPost httppost = new HttpPost(url);
 
		if (useTorProxy) {
			ConnRouteParams.setDefaultProxy(httppost.getParams(), host);
		} 
 
		if (referer != null) {
			httppost.addHeader("Referer", referer);
		} 
		List<NameValuePair> list = Arrays.asList(params);
 
		UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list, "UTF-8");
		httppost.setEntity(entity);
		// System.out.println("Posting to " + url + ", Request " + 
		// entity.getContentType() + " length " + entity.getContentLength()); 
		HttpResponse response = client.execute(httppost);
		HttpEntity responseEntity = response.getEntity();
		// System.out.println("Response length: " + 
		// responseEntity.getContentLength() + " Type " + 
		// responseEntity.getContentType()); 
 
Connect your IDE to all the code out there  Get Codota for Java