1. if(response.getEntity() != null && response.getEntity().getContent() != null)
  2. {
  3. message = IOUtils.toString(response.getEntity().getContent());
  4. }
会报Content has been consumed错误

这个问题是多次调用HttpEntity.getContent()导致的, Entity中的内容只能读取一次, 参考如下:

You can retrieve the content from the entity only once. If you have 
already extracted the content somewhere, and you try to fetch it 
again, it will throw this IllegalStateException. Check you code and 
make sure that you make this call only once.

看一下:http://blog.csdn.net/boonya/article/details/42740235

Content has been consumed的更多相关文章

  1. HTTPClient网络异常:java.lang.IllegalStateException: Content has been consumed

    在对代码进行重构时候,出现了一个异常,代码的网络请求使用的是HTTPClient: 但是其实代码中没有添加什么,只是添加了两句log: 后来发现是因为将EntityUtils.toString()方法 ...

  2. [置顶] Android开发笔记(成长轨迹)

    分类: 开发学习笔记2013-06-21 09:44 26043人阅读 评论(5) 收藏 Android开发笔记 1.控制台输出:called unimplemented OpenGL ES API ...

  3. HttpClient学习笔记

    HttpClient相关的实体类官方文档地址:http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/ 使用HttpClien ...

  4. How to Preloading content with rel preload

    The preload value of the <link> element's rel attribute allows you to write declarative fetch ...

  5. requests的content与text导致lxml的解析问题

    title: requests的content与text导致lxml的解析问题 date: 2015-04-29 22:49:31 categories: 经验 tags: [Python,lxml, ...

  6. Content Security Policy 入门教程

    阮一峰文章:Content Security Policy 入门教程

  7. android 使用Tabhost 发生could not create tab content because could not find view with id 错误

    使用Tabhost的时候经常报:could not create tab content because could not find view with id 错误. 总结一下发生错误的原因,一般的 ...

  8. 【解决方案】cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. One of '{"http://java.sun.com/xml/ns/javaee":run-as, "http://java.sun.com/xml/ns/javaee":security-role-r

    [JAVA错误] cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. One o ...

  9. 注意 AppResLib.dll.*.mui 的生成操作应该为 Content

    为 Windows Phone 8 App 添加本地化的时候,发现修改 AppResLib.dll.*.mui 后不仅没有其变化,还发现修改它导致它失效.通过对比代码发现,问题原因是 AppResLi ...

随机推荐

  1. MyBatis入门学习教程-实现关联表查询

    一.一对一关联 1.1.提出需求 根据班级id查询班级信息(带老师的信息) 1.2.创建表和数据 创建一张教师表和班级表,这里我们假设一个老师只负责教一个班,那么老师和班级之间的关系就是一种一对一的关 ...

  2. PHP扩展下载指导

    http://pecl.php.net/package/ 相信很多人为了找PHP扩展包,很发愁. 其实可以去官网下载,还有各个版本选择,不必担心下载到了错误版本,浪费时间以及网站积分. 简单说下方法: ...

  3. VS2010 无法计算HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0@VCTargetPath处的属性表达式

    VS2010打开.csproj工程文件报错,不能加载,错误信息如下: 无法计算HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\1 ...

  4. Atom插件推荐

    1.File Icons 为各种不同的文件显示icon 2.git plus 添加git的功能 3.atom-beauty 代码格式化工具 4.eclipse keybindings 在atom上使用 ...

  5. mysql临时表的产生

    sql执行会生成一个巨大的临时表,当内存放不下时,要全部copy 到磁盘,导致IO飙升,时间开销增大. 额外收获知识收藏如下: 临时表存储 MySQL临时表分为"内存临时表"和&q ...

  6. css属性在各种浏览器上的兼容性

    transform:在360急速浏览器不支持,在IE兼容性上看IE浏览器的版本,IE9+是支持.

  7. android中MVP模式

    http://blog.csdn.net/ysh06201418/article/details/46534799 Android App整体架构设计的思考   http://blog.csdn.ne ...

  8. 阐述ArrayList、Vector、LinkedList的存储性能和特性?(转)

    ArrayList 和Vector他们底层的实现都是一样的,都是使用数组方式存储数据,此数组元素数大于实际存储的数据以便增加和插入元素,它们都允许直接按序号索引元素,但是插入元素要涉及数组元素移动等内 ...

  9. FreeBSD从零开始---安装后配置(三)

    IPFW和IPF   一.IPFW IPFW意思可以理解为ip防火墙,主要作用是拦截设定规则外的ip包.你可以把这个理解为linux下的iptables,但是,ipfw要比iptables简单易用. ...

  10. C#预编译

    在C#开发中经常会遇到在Debug和Release模式下需要执行不同代码的情况,这个时候使用C#条件编译可以很好地解决这个问题,如 #if DEBUG // TO Do Debug Mode Code ...