Java File Name Get getFileNamesOld(File zipFile)

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

Description

http://www.java2novice.com/java-collections-and-util/zip/file-list/

License

Apache License

Parameter

Parameter Description
zipFile a parameter

Declaration

public static List<String> getFileNamesOld(File zipFile) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.io.IOException;

import java.util.ArrayList;

import java.util.Enumeration;
import java.util.List;

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

public class Main {
    /**/*from w w  w  .ja va2 s.c  o  m*/
     * http://www.java2novice.com/java-collections-and-util/zip/file-list/
     * 
     * @param zipFile
     * @return
     */
    public static List<String> getFileNamesOld(File zipFile) {
        List<String> filenames = new ArrayList<>();
        ZipFile z;
        try {
            z = new ZipFile(zipFile);
            Enumeration<? extends ZipEntry> en = z.entries();
            while (en.hasMoreElements()) {
                ZipEntry ze = en.nextElement();
                filenames.add(ze.getName());
            }
            z.close();
        } catch (ZipException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return filenames;
    }
}

Related

  1. getFilenames(String filenames)
  2. getFileNames(String path, boolean withFullPath)
  3. getFileNames_STR(String path)
  4. getFileNamesFromDir(File rootDir, String indexName)
  5. getFileNamesInJar(File source, String folder, String extension)
  6. getFileNamesRecursive(final String pDataDir, final FilenameFilter pFilter, final int pMaxFiles)
  7. getFileNameStartingWith(String directory, String prefix)
  8. getFilenameSuffix(final File file)
  9. getFileNameUtil(String dataPath)