ServiceData.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:otrta 作者:
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");
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号