未报告的异常IOException

时间:2019-09-30 15:26:10

标签: java android

我有错误:

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);

1 个答案:

答案 0 :(得分:0)

您遇到编译错误 您必须在方法签名的末尾添加一个引发异常的代码,或者将代码包装在try catch块中