从数据库中字段为byte的图片读取处理存入磁盘

来源:互联网 发布:软件外包服务平台 编辑:程序博客网 时间:2024/05/21 11:27
 if (!"".equals(attachmentvo.getFilePath())) {
    byte[] bytes1 = attachmentvo.getContexts();
    ByteArrayInputStream bis = new ByteArrayInputStream(bytes1);
    os = new FileOutputStream(outPath);
    buffer = new byte[4096];
    int len = 0;
    while ((len = bis.read(buffer)) != -1) {
     os.write(buffer, 0, len);
    }
    buffer = null;
    bis.close();
    os.close();
   }