HttpGet httpget = new HttpGet(url);
httpget.addHeader("Authorization", "Basic " + encoding);
CloseableHttpResponse response = null;
try {
response = httpclient.execute(httpget);
int status = response.getStatusLine().getStatusCode();
System.out.println(String.valueOf(status));
} catch (IOException e) {
e.printStackTrace();
}
HttpEntity entity1 = response.getEntity();
String result = null;
try {
result = EntityUtils.toString(entity1);
System.out.println(result);
} catch (ParseException | IOException e) {
e.printStackTrace();
}
return result;
}作者: starryEstrella 时间: 2018-4-30 16:26
Get reference from other sources, and it is proved to be very helpful, so post this so that more persons could check this. 作者: 181lzx 时间: 2018-4-30 20:39