我有错误:

error: unreported exception IOException; must be caught or declared to be thrown


码:

ToRestApi rest = new ToRestApi();
HttpResponse response = rest.postToRestApiToken(objEnrolment,"enrolment");

HttpEntity entity = response.getEntity();
final String finalStats = EntityUtils.toString(entity);


我尝试在Try Catch中使用它,但它也无法正常工作

错误关注:EntityUtils.toString(entity);

最佳答案

你有一个编译错误
您必须在您的方法签名末尾称量抛出异常,或将代码包装在try catch块中

10-01 07:30