Error in Selecting multiple files into one zip and downloading the zip file?
<pre><code>   &lt;% // Set the content type based to zip
    response.setContentType("Content-type:text/zip");
    response.setHeader("Content-Disposition", "attachment; filename=mytest.zip");

    // List of files to be downloaded
    List files = new ArrayList();
    files.add(new File("C:/first.txt"));
    files.add(new File("C:/second.txt"));
    files.add(new File("C:/third.txt"));

    ServletOutputStream out1 = response.getOutputStream();
    ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(out1));
    for (Object file : files) 
    {
        //System.out.println("Adding file " + file.getName());
        System.out.println("Adding file " + file.getClass().getName());
        //zos.putNextEntry(new ZipEntry(file.getName()));
        zos.putNextEntry(new ZipEntry(file.getClass().getName()));
        // Get the file
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(file);
        } catch (Exception E) {
            // If the file does not exists, write an error entry instead of file  contents
            //zos.write(("ERROR: Could not find file " + file.getName()).getBytes());
            zos.write(("ERROR: Could not find file" +file.getClass().getName()).getBytes());
            zos.closeEntry();
            //System.out.println("Could not find file "+ file.getAbsolutePath());
            continue;
        }
        BufferedInputStream fif = new BufferedInputStream(fis);
        // Write the contents of the file
        int data = 0;
        while ((data = fif.read()) != -1) {
            zos.write(data);
        }
        fif.close();
        zos.closeEntry();
        //System.out.println("Finished adding file " + file.getName());
        System.out.println("Finished adding file " + file.getClass().getName());
    }
    zos.close();
%&gt;
</code></pre>

<p>this is my actualy program , want to zip multiple file and then downloading it , is wat i am doing the way is right or wrong , am new to JAVA programming ,  can you help me out ???</p>
