public void downloadMutiFilesForDatabase(List<FileManager> fileManagerList,String fileName, HttpServletResponse response) throws Exception {
//FTPSClient ftpClient =null;
if(fileManagerList == null )
{
return;
}
ZipOutputStream zipOut = new ZipOutputStream(response.getOutputStream());
response.setCharacterEncoding("UTF-8");
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition", "attachment;fileName="+ new String((fileName+".zip").getBytes("UTF-8"),"ISO-8859-1"));
for (FileManager e : fileManagerList){
if(e.getSavename() != null){
ZipEntry z=new ZipEntry(e.getFilename());//这是文件名例如"我的文件.txt"
zipOut.putNextEntry(z);
zipOut.write(e.getSavename().getBytes());//这是文件内容
}
}
zipOut.flush();
zipOut.close();
}
Java 不需要本地生成文件zip打包
原创
©著作权归作者所有:来自51CTO博客作者wx61d3f2500ddd9的原创作品,请联系作者获取转载授权,否则将追究法律责任

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
写程序不需要天份,也不需要热情
。这种深植人心的刻板印象不
PHP Java 程序语言