图片信息应该不能通过这种方式提取,你可以检测图片的url然后自行下载到本地。

解决方案 »

  1.   

       测试toString后length大小比图片实际的小,而生成的图片比图片数据大。下载后存储过程中图片数据增加了!
       图片数据流toString过程中数据大小发生了改变,还原不回来。其它新闻内容没有问题。估计是图片的编码格式等的问题。在图片数据流读过来时直接生成图片就可以了。
      

  2.   


    public  int saveImage (String strUrl){
        URLConnection uc = null;
    try {
               URL url = new URL(strUrl);
               uc = url.openConnection();
               uc.setRequestProperty("User-Agent",  
                        "Mozilla/4.0 (compatible; MSIE 5.0; Windows XP; DigExt)");
               //uc.setReadTimeout(30000);
     //获取图片长度  
      //System.out.println("Content-Length:     "+uc.getContentLength()); 
      //获取文件头信息
       //System.out.println("Header"+uc.getHeaderFields().toString());  
               if (uc == null)
                   return 0;
               InputStream ins = uc.getInputStream(); 
                     byte[] str_b = new byte[1024];         
                 int byteRead=0;                           
                 String[] images=strUrl.split("/");
    String imagename=images[images.length-1];
               File fwl = new File(imagename);
               FileOutputStream fos= new FileOutputStream(fwl); 
               while ((byteRead=ins.read(str_b)) > 0) {
               fos.write(str_b,0,byteRead);
                      };
                     fos.flush();  
                  fos.close();
           } catch (Exception e) {
               e.printStackTrace();
               log.error("获取网页内容出错");
           }finally{
            uc = null;
           }
           return 1;
       }