public class ClassResourceUtils extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
ClassResourceUtils.FileFilter
文件名过滤器接口
|
| Constructor and Description |
|---|
ClassResourceUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.List<java.lang.String> |
getFilesUnchecked(java.lang.Class<?> clazz,
java.lang.String path,
ClassResourceUtils.FileFilter filter) |
static java.util.List<java.lang.String> |
getFilesUnchedked(java.lang.Class<?> clazz,
java.lang.String path)
|
static java.net.URL |
getResource(java.lang.Class<?> claz,
java.lang.String path)
Finds a resource with the given name.
|
static java.io.InputStream |
getResourceAsStream(java.lang.Class<?> clazz,
java.lang.String name)
Returns an input stream for reading the specified resource.
|
static java.util.List<java.lang.String> |
getResourceFileList(java.lang.Class<?> clazz,
java.lang.String dirPath)
List file names for a resource folder.
|
static java.lang.String |
normalizeDirPath(java.lang.String path)
Return a normalized directory path, end with "/", but not start with one
|
static java.lang.String |
normalizePath(java.lang.String path)
Return a context-relative path, beginning with a "/", that represents
the canonical version of the specified path after ".." and "." elements
are resolved out.
|
static boolean |
resourceExist(java.lang.Class<?> clazz,
java.lang.String resource)
Returns true if resource exist.
|
public ClassResourceUtils()
public static java.util.List<java.lang.String> getFilesUnchedked(java.lang.Class<?> clazz, java.lang.String path)
clazz - Class to use when getting the System classloaderpath - public static java.util.List<java.lang.String> getFilesUnchecked(java.lang.Class<?> clazz, java.lang.String path, ClassResourceUtils.FileFilter filter)
clazz - Class to use when getting the System classloaderpath - filter - A filename filtergetFilesUnchedked(Class, String)public static boolean resourceExist(java.lang.Class<?> clazz, java.lang.String resource)
clazz - Class to use when getting the System classloaderresource - public static java.lang.String normalizePath(java.lang.String path)
null instead.path - Path to be normalizedpublic static java.lang.String normalizeDirPath(java.lang.String path)
path - Path to be normalizednormalizePath(String)public static java.io.InputStream getResourceAsStream(java.lang.Class<?> clazz, java.lang.String name)
clazz - Class to use when getting the System classloader (used if no Thread
Context classloader available or fails to get resource).name - name of the resourcegetResource(Class, String)public static java.net.URL getResource(java.lang.Class<?> claz, java.lang.String path)
Class.getResourceAsString when the resource
might come from a different classloader. (e.g. a webapp).claz - Class to use when getting the System classloader (used if no Thread
Context classloader available or fails to get resource).path - name of the resourcepublic static java.util.List<java.lang.String> getResourceFileList(java.lang.Class<?> clazz, java.lang.String dirPath) throws java.io.IOException
clazz - Any java class that lives in the same place as the resources you want.dirPath - java.io.IOExceptionCopyright © 2019. All rights reserved.