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

org.springframework.biz.utils.SpringClassFileUtils Maven / Gradle / Ivy

There is a newer version: 3.3.x.20241003.RELEASE
Show newest version
package org.springframework.biz.utils;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Collection;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.FileFilterUtils;


/**
 * Classpath 根目录资源文件加载工具
 */
public abstract class SpringClassFileUtils {

	//得到classpath 根目录
	public static File getClassRoot() throws FileNotFoundException{
		return SpringResourceUtils.getFile("classpath:");
	}
	
	public static File[] getClassPathFiles(String suffix) throws IOException {
		//得到classpath 根目录
		File classPath = SpringClassFileUtils.getClassRoot();
		//遍历根目录,仅仅取得指定后缀的文件
		Collection files = FileUtils.listFiles(classPath, FileFilterUtils.suffixFileFilter(suffix), null);
		return files.toArray(new File[]{});
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy