通过httpClient4读取页面内容

HttpClient httpClient = new DefaultHttpClient();
		HttpClientParams.setCookiePolicy(httpClient.getParams(), CookiePolicy.BROWSER_COMPATIBILITY);  
		HttpHost httpHost = new HttpHost("localhost");
		HttpGet httpGet = new HttpGet("/https/");
		
		HttpResponse response = httpClient.execute(httpHost,httpGet);
		
		if(HttpStatus.SC_OK==response.getStatusLine().getStatusCode()){
			//请求成功
			//取得请求内容
			HttpEntity entity = response.getEntity();
			//显示内容
			if (entity != null) {
				// 显示结果
			System.out.println(EntityUtils.toString(entity,"utf-8"));
			}
		}
		httpGet.abort();

你可能感兴趣的:(java)