Here you can find the source of getMatchingResourcesFromJar(JarFile jarFile, String suffix)
Parameter | Description |
---|---|
jarFile | : the jar in which search for resources must be performed |
suffix | : the suffix resources must match. If null all resources will be retrieved |
public static List<String> getMatchingResourcesFromJar(JarFile jarFile, String suffix)
//package com.java2s; /*// w w w . ja v a2 s . co m * (c) Copyright 2010-2011 AgileBirds * * This file is part of OpenFlexo. * * OpenFlexo 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. * * OpenFlexo 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with OpenFlexo. If not, see <http://www.gnu.org/licenses/>. * */ 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 { /** * Retrieve all resources with the specified suffix in the jar. * * @param jarFile : the jar in which search for resources must be performed * @param suffix : the suffix resources must match. If null all resources will be retrieved * @return the retrieved resource names. */ public static List<String> getMatchingResourcesFromJar(JarFile jarFile, String suffix) { List<String> result = new ArrayList<String>(); Enumeration<JarEntry> entries = jarFile.entries(); // gives ALL entries in jar while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (suffix == null || entry.getName().endsWith(suffix)) result.add("/" + entry.getName()); } return result; } }