All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.webframe.support.util.ResourceUtils Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy