在我的列表中,我有多个文件,但在下载时,我的列表中的第一个文件正在下载。
for(FileAttachemntActionVo fileAttachemntActionVoItr : fileAttachemntActionVoList){
ServletOutputStream out = servletResponse.getOutputStream();
servletResponse.setContentType("multipart/x-mixed-replace;boundary=END");
servletResponse.setHeader("Content-Disposition","attachment; filename="+fileAttachemntActionVoItr.getAttachmentFileName());
//}
FileInputStream fileInputStream = null;
try{
fileInputStream = new FileInputStream(fileAttachemntActionVoItr.getAttachmentUrl() + fileAttachemntActionVoItr.getAttachmentFileName());
}catch(FileNotFoundException fnfe){
fnfe.getStackTrace();
}
BufferedInputStream fif = new BufferedInputStream(fileInputStream);
int i = 0;
while ((i = fif.read()) != -1) {
out.write(i);
}
fif.close();
out.close();
}