1.Spring自带方法,定义输出流就可以写入文件

                final OutputStream os;
                os = new FileOutputStream(new File("300.zip"));
                FileCopyUtils.copy(blob.getBinaryStream(), os);

2.转成byte[]后写入

                Blob blob = rs.getBlob("FSTREAM");
                ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
                InputStream inputStream = blob.getBinaryStream();
                byte[] buff = new byte[100]; //buff用于存放循环读取的临时数据
                int rc = 0;
                while ((rc = inputStream.read(buff, 0, 100)) > 0) {
                    swapStream.write(buff, 0, rc);
                }
                byte[] fStreamByte = swapStream.toByteArray(); //in_b为转换之后的结果
                final OutputStream os;
                os = new FileOutputStream(new File("300.zip"));
                os.write(fStreamByte);
                os.close();

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-09
  • 2022-12-23
  • 2021-11-18
  • 2021-08-07
  • 2021-11-27
  • 2018-03-16
  • 2021-10-11
相关资源
相似解决方案