0

Here in my list i am having multiple files but while downloading only the first file in my list is getting downloaded.

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();
        }

1 Answers1

1

Do not close the output stream, take a look at this post. Let the container handle the stream.

Nikolas
  • 2,066
  • 1
  • 19
  • 20