| | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import org.apache.poi.util.IOUtils; |
| | | import org.apache.poi.xssf.streaming.SXSSFSheet; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 下载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)); |
| | | } |