enter code here
String getUrl =“ https:// xyz”; HttpGet httpget = null;
try {
httpclient = HttpClients.createDefault();
ResponseHandler<String> responseHandler = response -> {
int status = response.getStatusLine().getStatusCode();
HttpEntity resMsg2 = response.getEntity();
if (status >= 200 && status < 300) {
HttpEntity entity = response.getEntity();
return entity != null ? EntityUtils.toString(entity) : null;
} if (status >= 500) {
HttpEntity entity2 = response.getEntity();
return entity2 != null ? EntityUtils.toString(entity2) : null;
}
else {
System.out.println("resMsg :--"+resMsg2);
throw new ClientProtocolException("Unexpected response status SS : " + status);
}
};
JSONParser JSONparse = new JSONParser();
httpget = new HttpGet(getUrl);
httpget.addHeader("accept", "application/");
String responseBody2 = httpclient.execute(httpget, responseHandler);
System.out.println("value of response body:"+responseBody2);
}
catch(Exception e)
{
System.out.println(e);
}
finally {
httpget.releaseConnection();
}
我要这样放下
Ò>è?ô??R§(|÷>} *&ðP_øº7y_j½ÿ§±ói?ä?¡ø½?E?íúgÉç= s9????eùú©ç²¤ç¶²?}? :ÿÉ'?`Y#»ÛâmçR?ÙÃu´·