标签:and random file 错误 代码 close response try ons
OutputStream out = response.getOutputStream();
ZipOutputStream zos = new ZipOutputStream(out);
XSSFWorkbook workbook = new XSSFWorkbook();
// 将文件写入zip内,即将文件进行打包
zos.putNextEntry(new ZipEntry(fileName + "(" + UUID.randomUUID() + ")." + typeName));
// 此处将自动关闭zos资源
workbook.wirte(zos);
OutputStream out = response.getOutputStream();
ZipOutputStream zos = new ZipOutputStream(out);
XSSFWorkbook workbook = new XSSFWorkbook();
// 将文件写入zip内,即将文件进行打包
zos.putNextEntry(new ZipEntry(fileName + "(" + UUID.randomUUID() + ")." + typeName));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
workbook.write(bos);
bos.writeTo(zos);
zos.closeEntry();
// 当所有文件打包完成后关闭zos资源
zos.close();
XSSFWorkbook对象 进行zip打包时 用write资源流自动关闭处理办法
标签:and random file 错误 代码 close response try ons
原文地址:https://www.cnblogs.com/bradcai/p/11344247.html