Android Zip Entry Get getEntriesNames(File zipFile)

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

Description

get Entries Names

License

Apache License

Declaration

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

Method Source Code

//package com.java2s;
/*// w w  w . j a  v a2  s.c o m
 * Copyright (c) 2014,KJFrameForAndroid Open Source Project,??.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

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("GB2312"), "8859_1"));
        }
        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("GB2312"), "8859_1");
    }
}

Related

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