Can ANYBODY explain why the enumerated files are overwriting the previously
zipped file in the .zip file so that only the last file shows up in the
.zip?

Thanks,
Mark

public static void addFilesToZip( Vector files) {
    Enumeration enum = files.elements();

    try {
        while( enum.hasMoreElements()) {
            File file = (File) enum.nextElement();
            String zip = zipFile.getCanonicalPath().toString();
            FileOutputStream fos = new FileOutputStream( zip);
            CheckedOutputStream csum = new CheckedOutputStream( fos, new
Adler32());
            ZipOutputStream zos = new ZipOutputStream( new
BufferedOutputStream( csum));
            System.out.println( "\nCompressing and adding file " + file + "
to " + zip + "....");
            BufferedReader br = new BufferedReader( new FileReader( file));
            zos.putNextEntry( new ZipEntry(
file.getAbsolutePath().toString()));

            System.out.println( "Buffer size = " + br.read() + " bytes");
            while( br.read() != -1) {
                zos.write( br.read());
            }

            br.close();
            zos.close();
            System.out.println( "File checksum: " +
csum.getChecksum().getValue());
            //System.out.println( "Deleting file: " + file);
            //file.delete();
        }
    } catch( NoSuchElementException e) {
        e.printStackTrace();
    } catch( FileNotFoundException e) {
        e.printStackTrace();
    } catch( ZipException e) {
        e.printStackTrace();
    } catch( IOException e) {
        e.printStackTrace();
    }
}



I am a deeply superficial person.  -Andy Warhol

This email was scanned with Norton AntiVirus 2002 before sending.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to