yaozc2021
2024-12-25 7df667ff109e5cdccb61305140f81d60856f4ff4
eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
@@ -351,6 +351,24 @@
        }
    }
    /**
     * 下载ZIP
     */
    public static void downloadZip(ByteArrayOutputStream byteArrayOutputStream, HttpServletResponse response) throws IOException {
        // response为HttpServletResponse对象
        response.setContentType("application/zip");
        // test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
        response.setHeader("Content-Disposition", "attachment;filename=file.zip");
        // ServletOutputStream
        ServletOutputStream out = response.getOutputStream();
        // 写入
        out.write(byteArrayOutputStream.toByteArray());
        // flush
        out.flush();
        //此处记得关闭输出Servlet流
        IoUtil.close(out);
    }
    public static String getMd5(File file) {
        return getMd5(getByte(file));
    }