org.webframe.support.util.ResourceUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wf-support Show documentation
Show all versions of wf-support Show documentation
Java Web Frame: wf-support
package org.webframe.support.util;
import java.io.IOException;
import java.net.JarURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import org.springframework.core.io.Resource;
import org.webframe.support.driver.resource.jar.JarResourcePatternResolver;
/**
* ResourceUtils
*
* @author 黄国庆
* @since 2012-4-27 下午1:50:44
* @version
*/
public class ResourceUtils extends org.springframework.util.ResourceUtils {
public static List getUrls(String path) throws IOException {
Enumeration enumeration = ClassUtils.getDefaultClassLoader()
.getResources(path);
List urls = new ArrayList();
while (enumeration.hasMoreElements()) {
urls.add(enumeration.nextElement());
}
return urls;
}
public static List loadResources(List urls, String pattern)
throws IOException {
List resources = new ArrayList();
for (JarURLConnection jarURLConnection : urls) {
JarResourcePatternResolver jrpr = new JarResourcePatternResolver(jarURLConnection);
resources.addAll(Arrays.asList(jrpr.getResources(pattern)));
}
return resources;
}
}