Wednesday, December 9, 2009

List The Contents of a ZIP File

This is a utility program to view the contents of a zip file


import java.io.IOException;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

/**
 *
 * @author Rakesh P
 * ZipFile Function Accept the Path of the Zip File 
 */
public class ZipContents{
   
    public void listContentsOfZipFile() {
       
        try {
            ZipFile zipFile = new ZipFile("d:/FeedtoInterfaces.zip");
           
            Enumeration zipEntries = zipFile.entries();
           
            while (zipEntries.hasMoreElements()) {
               
                //Process the name, here we just print it out
                System.out.println(((ZipEntry)zipEntries.nextElement()).getName());
               
            }
           
        } catch (IOException ex) {
            ex.printStackTrace();
        }
       
    }
   
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       
        new  ZipContents().listContentsOfZipFile();
       
    }
}

1 comment:

Alexis said...

I know a lot of types of files,but zip archives for me are quite difficult. Because of often some of them are corrupted and no one knows how. But yesterday I was in the Internet and noticed there - check integrity of zip file. It restored all my corrupted zip files. Besides the tool performed it without money.