今天调试程序时,debug到下面这段代码时出的问题,具体是大括号里面的那句:
抛出的异常是:
原因是在if的逻辑判断里已经调用过一次getContent方法,而此方法只能调用一次。
if(response.getEntity() != null && response.getEntity().getContent() != null)
{
message = IOUtils.toString(response.getEntity().getContent());
}
抛出的异常是:
java.lang.IllegalStateException: Content has been consumed
原因是在if的逻辑判断里已经调用过一次getContent方法,而此方法只能调用一次。