Java ZipEntry Read getZipEntry(String zipFileLoc)

Here you can find the source of getZipEntry(String zipFileLoc)

Description

Get File entries and size from a zip file...

License

Open Source License

Parameter

Parameter Description
tarFileLoc a parameter
location a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static Map<String, Long> getZipEntry(String zipFileLoc) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.FileInputStream;

import java.io.IOException;

import java.util.HashMap;

import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Main {
    /**/*from  w ww .  jav  a  2s.c  o  m*/
     * Get File entries and size from a zip file...
     * 
     * @param tarFileLoc
     * @param location
     * @throws IOException
     */
    public static Map<String, Long> getZipEntry(String zipFileLoc) throws IOException {

        ZipInputStream zipIn = null;
        Map<String, Long> entryMap = null;
        try {
            zipIn = new ZipInputStream(new FileInputStream(zipFileLoc));
            ZipEntry entry = zipIn.getNextEntry();
            entryMap = new HashMap<String, Long>();
            while (entry != null) {
                if (!entry.isDirectory()) {
                    entryMap.put(entry.getName(), entry.getSize());
                }
                zipIn.closeEntry();
                entry = zipIn.getNextEntry();
            }
        } finally {
            if (zipIn != null) {
                zipIn.close();
            }

        }
        return entryMap;

    }
}

Related

  1. getSimpleName(ZipEntry entry)
  2. getZipEntry(File f, String nameToRead, String fileName)
  3. getZipEntry(final ZipFile zipFile, final CharSequence zippedName)
  4. getZipEntry(String name, ZipFile zipFile)
  5. getZipEntry(String zipEntryName)
  6. getZipEntry(ZipFile jarFile, String path)
  7. getZipEntry(ZipFile zip, final String name)
  8. getZipEntry(ZipFile zip, String name)
  9. getZipEntryAsString(File archive, String name)