Android Zip Entry Get GetFileList(String zipFileString, boolean bContainFolder, boolean bContainFile)

Here you can find the source of GetFileList(String zipFileString, boolean bContainFolder, boolean bContainFile)

Description

Get File List

Declaration

public static List<File> GetFileList(String zipFileString,
        boolean bContainFolder, boolean bContainFile) throws Exception 

Method Source Code

//package com.java2s;
import java.io.File;
import java.io.FileInputStream;

import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;

import java.util.zip.ZipInputStream;

public class Main {

    public static List<File> GetFileList(String zipFileString,
            boolean bContainFolder, boolean bContainFile) throws Exception {

        List<File> fileList = new ArrayList<File>();
        ZipInputStream inZip = new ZipInputStream(new FileInputStream(
                zipFileString));/*w  ww . ja  va2  s .co m*/
        ZipEntry zipEntry;
        String szName = "";

        while ((zipEntry = inZip.getNextEntry()) != null) {
            szName = zipEntry.getName();

            if (zipEntry.isDirectory()) {

                // get the folder name of the widget
                szName = szName.substring(0, szName.length() - 1);
                File folder = new File(szName);
                if (bContainFolder) {
                    fileList.add(folder);
                }

            } else {
                File file = new File(szName);
                if (bContainFile) {
                    fileList.add(file);
                }
            }
        }// end of while

        inZip.close();

        return fileList;
    }
}

Related

  1. getEntryName(ZipEntry entry)
  2. getEntryName(ZipEntry entry)
  3. getEntryName(ZipEntry entry)
  4. GetFileList( String zipFileString, boolean bContainFolder, boolean bContainFile)
  5. GetFileList(String zipFileString, boolean bContainFolder, boolean bContainFile)
  6. isIgnore(final ZipEntry ze)
  7. getExtension(final ZipEntry ze)