httpclient请求去掉返回结果string中的多余转义字符
- 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("
", "");
- }
- else
- httpRequst.abort();
- } catch (ClientProtocolException e) {
-
- e.printStackTrace();
- result = e.getMessage().toString();
- } catch (IOException e) {
-
- e.printStackTrace();
- result = e.getMessage().toString();
- }
- return result;
- }
原文地址:https://www.cnblogs.com/panxuejun/p/7623844.html