- public String doGet()
- {
- String uriAPI = "http://XXXXX?str=I+am+get+String";
- String result= "";
- HttpGet httpRequst = new HttpGet(uriAPI);
-
- try {
-
- HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequst);
- if(httpResponse.getStatusLine().getStatusCode() == 200)
- {
- HttpEntity httpEntity = httpResponse.getEntity();
- result = EntityUtils.toString(httpEntity);
-
- result.replaceAll("\r", "");
- }
- else
- httpRequst.abort();
- } catch (ClientProtocolException e) {
-
- e.printStackTrace();
- result = e.getMessage().toString();
- } catch (IOException e) {
-
- e.printStackTrace();
- result = e.getMessage().toString();
- }
- return result;
- }
posted @
2017-10-03 15:57
跨境电商杂货铺
阅读(
1877)
评论()
编辑
收藏
举报