public class ClassLoaderUtils extends Object
| Constructor and Description |
|---|
ClassLoaderUtils() |
| Modifier and Type | Method and Description |
|---|---|
static URL |
getResource(String resourceName,
Class callingClass)
Load a given resource.
|
static InputStream |
getResourceAsStream(String resourceName,
Class callingClass)
This is a convenience method to load a resource as a stream.
|
static Class |
loadClass(String className,
Class callingClass)
Load a class with a given name.
|
static Class |
loadClass(String className,
ClassLoader callingClassLoader)
Load a class with a given name.
|
public static Class loadClass(String className, Class callingClass) throws ClassNotFoundException
It will try to load the class in the following order:
Thread.currentThread().getContextClassLoader()
Class.forName(java.lang.String)
ClassLoaderUtil.class.getClassLoader()
callingClass.getClassLoader()
className - The name of the class to loadcallingClass - The Class object of the calling objectClassNotFoundException - If the class cannot be found anywhere.public static Class loadClass(String className, ClassLoader callingClassLoader) throws ClassNotFoundException
It will try to load the class in the following order:
Thread.currentThread().getContextClassLoader()
Class.forName(java.lang.String)
ClassLoaderUtil.class.getClassLoader()
callingClass.getClassLoader()
className - The name of the class to loadcallingClassLoader - The ClassLoader the calling object which will be used to look up classNameClassNotFoundException - If the class cannot be found anywhere.public static URL getResource(String resourceName, Class callingClass)
This method will try to load the resource using the following methods (in order):
resourceName - The name of the resource to loadcallingClass - The Class object of the calling objectpublic static InputStream getResourceAsStream(String resourceName, Class callingClass)
resourceName - The name of the resource to loadcallingClass - The Class object of the calling objectCopyright © 2018 Atlassian. All rights reserved.