`

读取blob格式图片上传到服务器目录

    博客分类:
  • java
阅读更多

//得到blob格式图片

String fileUrl = "url";
  Blob blob1 = vo.getPicture();
  InputStream image=null;
  if (blob1 != null && blob1.length() > 0) {
   java.io.FileOutputStream fout = null;

//写入流中
   fout = new java.io.FileOutputStream(fileUrl);
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   InputStream in =  blob1.getBinaryStream();
    int len;
             byte buf[] = new byte[1024];
        
             while ((len = in.read(buf, 0, 1024)) != -1) {
                 fout.write(buf, 0, len);              
             }
             fout.close();
           
  }

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics