Java Jar Usage getJarInFileList(JarFile jarFile, String targetPath)

Here you can find the source of getJarInFileList(JarFile jarFile, String targetPath)

Description

get Jar In File List

License

Open Source License

Declaration

public static List<String> getJarInFileList(JarFile jarFile, String targetPath) throws Exception 

Method Source Code

//package com.java2s;
/*/*w w  w .  ja  v  a2  s  .c  o m*/
file of LaBeeFramework
https://www.bee-wkspace.com/
    
Copyright (C) 2016- Naoki Yoshioka (ARTS Laboratory)
http://www.arts-lab.net/dev/
    
This library is free software; you can redistribute it and/or 
modify it under the terms of the GNU Lesser General Public License 
as published by the Free Software Foundation; 
either version 3 of the License, or any later version.
    
This library is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
See the GNU Lesser General Public License for more details.
*/

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

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

public class Main {

    public static List<String> getJarInFileList(JarFile jarFile, String targetPath) throws Exception {
        List<String> list = new ArrayList<String>();

        for (Enumeration<JarEntry> e = jarFile.entries(); e.hasMoreElements();) {
            JarEntry entry = e.nextElement();

            String name = entry.getName();
            if (name.startsWith(targetPath)) {
                list.add(name);
            }
        }
        return list;
    }
}

Related

  1. getAttribute(String name, String value)
  2. getClassNameByJar(String jarPath, boolean childPackage)
  3. getEntriesName(String jarFileName)
  4. getFileNamesWithSuffixForJarFile(JarFile jar, String suffix)
  5. getInfo(String jarFileName)
  6. getMatchingResourcesFromJar(JarFile jarFile, String suffix)
  7. getSortedAttributes(Attributes mainAttributes)
  8. getSortedJarEntries(JarFile jarFile)
  9. isSet(Attributes attributes, String name)