public static String HttpGetAnswer(String url) throws ClientProtocolException, IOException, JSONException, HttpException{
AndroidHttpClient client = AndroidHttpClient.newInstance(null);
client.getParams().setParameter(HttpConnectionParams.CONNECTION_TIMEOUT, 7500);
client.getParams().setParameter(HttpConnectionParams.SO_TIMEOUT, 7500);
HttpGet httpGet = new HttpGet(url);
HttpResponse response = client.execute(httpGet);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
String resp = EntityUtils.toString(response.getEntity());
client.close();
return resp;
} else {
try {
client.close();
}catch (Exception ex){}
throw new HttpException("STATUSCODE!=200");
}
}
ServiceData.java 文件源码
java
阅读 25
收藏 0
点赞 0
评论 0
项目:otrta
作者:
评论列表
文章目录