public enum ClassLoaderHelper extends Enum<ClassLoaderHelper>
限定符和类型 | 方法和说明 |
---|---|
static URL |
getResource(String resource,
boolean classesFirst,
Class<?>... classes)
If classesFirst is false, retrieves the resource via the context class
loader of the current thread, and if not found, via the class loaders of
the optionally specified classes in the order of their specification, and
if not found, from the class loader of
ClassLoaderHelper as the
last resort. |
static URL |
getResource(String resource,
Class<?>... classes)
Retrieves the resource via the context class loader of the current
thread, and if not found, via the class loaders of the optionally
specified classes in the order of their specification, and if not
found, from the class loader of
ClassLoaderHelper as the last
resort. |
static InputStream |
getResourceAsStream(String resource,
boolean classesFirst,
Class<?>... classes)
If classesFirst is false, retrieves the resource as an input stream via
the context class loader of the current thread, and if not found, via the
class loaders of the optionally specified classes in the order of their
specification, and if not found, from the class loader of
ClassLoaderHelper as the last resort. |
static InputStream |
getResourceAsStream(String resource,
Class<?>... classes)
Retrieves the resource as an input stream via
the context class loader of the current thread, and if not found, via the
class loaders of the optionally specified classes in the order of their
specification, and if not found, from the class loader of
ClassLoaderHelper as the last resort. |
static Class<?> |
loadClass(String fqcn,
boolean classesFirst,
Class<?>... classes)
If classesFirst is false, loads the class via the context class
loader of the current thread, and if not found, via the class loaders of
the optionally specified classes in the order of their specification, and
if not found, from the caller class loader as the
last resort.
|
static Class<?> |
loadClass(String fqcn,
Class<?>... classes)
Loads the class via the optionally specified classes in the order of
their specification, and if not found, via the context class loader of
the current thread, and if not found, from the caller class loader as the
last resort.
|
static ClassLoaderHelper |
valueOf(String name)
返回带有指定名称的该类型的枚举常量。
|
static ClassLoaderHelper[] |
values()
按照声明该枚举类型的常量的顺序, 返回
包含这些常量的数组。
|
public static ClassLoaderHelper[] values()
for (ClassLoaderHelper c : ClassLoaderHelper.values()) System.out.println(c);
public static ClassLoaderHelper valueOf(String name)
name
- 要返回的枚举常量的名称。IllegalArgumentException
- 如果该枚举类型没有带有指定名称的常量NullPointerException
- 如果参数为空值public static URL getResource(String resource, Class<?>... classes)
ClassLoaderHelper
as the last
resort.resource
- resource to be loadedclasses
- class loader providerspublic static URL getResource(String resource, boolean classesFirst, Class<?>... classes)
ClassLoaderHelper
as the
last resort.
If classesFirst is true, retrieves the resource via the optionally
specified classes in the order of their specification, and if not found,
via the context class loader of the current thread, and if not found,
from the class loader of ClassLoaderHelper
as the last resort.
resource
- resource to be loadedclassesFirst
- true if the class loaders of the optionally specified classes
take precedence over the context class loader of the current
thread; false if the opposite is true.classes
- class loader providerspublic static Class<?> loadClass(String fqcn, Class<?>... classes) throws ClassNotFoundException
fqcn
- fully qualified class name of the target class to be loadedclasses
- class loader providersClassNotFoundException
- if failed to load the classpublic static Class<?> loadClass(String fqcn, boolean classesFirst, Class<?>... classes) throws ClassNotFoundException
If classesFirst is true, loads the class via the optionally specified classes in the order of their specification, and if not found, via the context class loader of the current thread, and if not found, from the caller class loader as the last resort.
fqcn
- fully qualified class name of the target class to be loadedclassesFirst
- true if the class loaders of the optionally specified classes
take precedence over the context class loader of the current
thread; false if the opposite is true.classes
- class loader providersClassNotFoundException
- if failed to load the classpublic static InputStream getResourceAsStream(String resource, Class<?>... classes)
ClassLoaderHelper
as the last resort.resource
- resource to be loadedclasses
- class loader providerspublic static InputStream getResourceAsStream(String resource, boolean classesFirst, Class<?>... classes)
ClassLoaderHelper
as the last resort.
If classesFirst is true, retrieves the resource as an input stream via
the optionally specified classes in the order of their specification, and
if not found, via the context class loader of the current thread, and if
not found, from the class loader of ClassLoaderHelper
as the last
resort.
resource
- resource to be loadedclassesFirst
- true if the class loaders of the optionally specified classes
take precedence over the context class loader of the current
thread; false if the opposite is true.classes
- class loader providersCopyright © 2016. All rights reserved.