Android Zip Entry Get getEntriesNames(File zipFile)

Here you can find the source of getEntriesNames(File zipFile)

Description

get Entries Names

Declaration

public static ArrayList<String> getEntriesNames(File zipFile)
        throws ZipException, IOException 

Method Source Code

//package com.java2s;
import org.apache.http.protocol.HTTP;

import java.io.File;

import java.io.IOException;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;

import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;

public class Main {

    public static ArrayList<String> getEntriesNames(File zipFile)
            throws ZipException, IOException {
        ArrayList<String> entryNames = new ArrayList<String>();
        Enumeration<?> entries = getEntriesEnumeration(zipFile);
        while (entries.hasMoreElements()) {
            ZipEntry entry = ((ZipEntry) entries.nextElement());
            entryNames.add(new String(getEntryName(entry).getBytes(
                    HTTP.UTF_8), "8859_1"));
        }//w  ww.  j  av a  2 s  . c om
        return entryNames;
    }

    public static Enumeration<?> getEntriesEnumeration(File zipFile)
            throws ZipException, IOException {
        ZipFile zf = new ZipFile(zipFile);
        return zf.entries();
    }

    public static String getEntryName(ZipEntry entry)
            throws UnsupportedEncodingException {
        return new String(entry.getName().getBytes(HTTP.UTF_8), "8859_1");
    }
}

Related

  1. getEntriesEnumeration(File zipFile)
  2. getEntriesNames(File zipFile)
  3. getEntriesNames(File zipFile)
  4. getEntriesNames(File zipFile)
  5. getEntriesNames(File zipFile)
  6. getEntriesNames(File zipFile)
  7. getEntryComment(ZipEntry entry)
  8. getEntryComment(ZipEntry entry)
  9. getEntryComment(ZipEntry entry)