Http Get请求:
需要用到两个jar包:httpclient-4.3.2.jar、httpcore-4.3.2.jar
</pre><pre name="code" class="java"><span style="font-size:18px;"><span style="white-space:pre"> </span>String url = "";//这里是要访问的地址
HttpGet request = new HttpGet(url);
String result="";
try {
HttpResponse response = HttpClients.createDefault().execute(request);
if (response.getStatusLine().getStatusCode() == 200) {
result= EntityUtils.toString(response.getEntity());
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}</span>
最后返回的是一个String 类型的数据。