Java Jar Usage listFiles(JarFile jarFile, String path)

Here you can find the source of listFiles(JarFile jarFile, String path)

Description

list Files

License

Open Source License

Declaration

private static Set<String> listFiles(JarFile jarFile, String path) 

Method Source Code

//package com.java2s;
/* ========================================================================
 * PlantUML : a free UML diagram generator
 * ========================================================================
 *
 * (C) Copyright 2009-2017, Arnaud Roques
 *
 * Project Info:  http://plantuml.com/*w  ww . j av  a 2s .  c  om*/
 * 
 * If you like this project or if you find it useful, you can support us at:
 * 
 * http://plantuml.com/patreon (only 1$ per month!)
 * http://plantuml.com/paypal
 * 
 * This file is part of PlantUML.
 *
 * PlantUML is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * PlantUML 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 General Public
 * License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
 * USA.
 *
 *
 * Original Author:  Arnaud Roques
 * 
 *
 */

import java.util.Enumeration;
import java.util.Set;
import java.util.TreeSet;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

public class Main {
    private static Set<String> listFiles(JarFile jarFile, String path) {
        final Enumeration<JarEntry> entries = jarFile.entries();
        final Set<String> result = new TreeSet<String>();
        while (entries.hasMoreElements()) {
            final String name = entries.nextElement().getName();
            if (name.startsWith(path)) {
                result.add(name.substring(path.length()));
            }
        }
        return result;
    }
}

Related

  1. getJarInFileList(JarFile jarFile, String targetPath)
  2. getMatchingResourcesFromJar(JarFile jarFile, String suffix)
  3. getSortedAttributes(Attributes mainAttributes)
  4. getSortedJarEntries(JarFile jarFile)
  5. isSet(Attributes attributes, String name)
  6. process(Object obj)
  7. processJarFile(String f)
  8. recordFactoryDefault(String className, Attributes attributes)
  9. safeClose(JarFile jf)