Java File Name Get getFileNamesInJar(File source, String folder, String extension)

Here you can find the source of getFileNamesInJar(File source, String folder, String extension)

Description

get File Names In Jar

License

Open Source License

Declaration

public static ArrayList<String> getFileNamesInJar(File source, String folder, String extension) 

Method Source Code


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

import java.io.File;

import java.util.ArrayList;
import java.util.Enumeration;

import java.util.jar.JarEntry;
import java.util.jar.JarFile;

public class Main {
    public static ArrayList<String> getFileNamesInJar(File source, String folder, String extension) {
        ArrayList<String> list = new ArrayList();
        try {/*from w  w  w  .ja  va2 s.  c  om*/
            JarFile jarFile = new JarFile(source);
            Enumeration e = jarFile.entries();
            while (e.hasMoreElements()) {
                JarEntry je = (JarEntry) e.nextElement();
                if (je.isDirectory() || !je.getName().endsWith(extension) || !je.getName().startsWith(folder)) {
                    continue;
                }
                list.add(je.getName());
            }
            jarFile.close();
        } catch (Throwable t) {
            t.printStackTrace();
        }
        return list;
    }
}

Related

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