通过httpClient获取http接口返回数据并转换为泛型List

public static  List getResultForArray(String url, Class clazz) {
        List re = null;
        try {
            String result = HttpClientUtil.doGet(url);
            if (result != null && result.length() > 0) {
                re = JSONArray.parseArray(result, clazz);
            }
        } catch (Exception e) {
            LOGGER.info("url:" + url);
            LOGGER.info("Http请求异常", e);
        }
        return re;
    }

 

你可能感兴趣的:(Java)