|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.alibaba.druid.support.logging.Resources
public final class Resources
A class to simplify access to resources through the classloader.
| Method Summary | |
|---|---|
static Class<?> |
classForName(String className)
Loads a class |
static Charset |
getCharset()
|
static ClassLoader |
getDefaultClassLoader()
Returns the default classloader (may be null). |
static File |
getResourceAsFile(ClassLoader loader,
String resource)
Returns a resource on the classpath as a File object |
static File |
getResourceAsFile(String resource)
Returns a resource on the classpath as a File object |
static Properties |
getResourceAsProperties(ClassLoader loader,
String resource)
Returns a resource on the classpath as a Properties object |
static Properties |
getResourceAsProperties(String resource)
Returns a resource on the classpath as a Properties object |
static Reader |
getResourceAsReader(ClassLoader loader,
String resource)
Returns a resource on the classpath as a Reader object |
static Reader |
getResourceAsReader(String resource)
Returns a resource on the classpath as a Reader object |
static InputStream |
getResourceAsStream(ClassLoader loader,
String resource)
Returns a resource on the classpath as a Stream object |
static InputStream |
getResourceAsStream(String resource)
Returns a resource on the classpath as a Stream object |
static URL |
getResourceURL(ClassLoader loader,
String resource)
Returns the URL of the resource on the classpath |
static URL |
getResourceURL(String resource)
Returns the URL of the resource on the classpath |
static Properties |
getUrlAsProperties(String urlString)
Gets a URL as a Properties object |
static Reader |
getUrlAsReader(String urlString)
Gets a URL as a Reader |
static InputStream |
getUrlAsStream(String urlString)
Gets a URL as an input stream |
static Object |
instantiate(Class<?> clazz)
Creates an instance of a class |
static Object |
instantiate(String className)
Creates an instance of a class |
static void |
setCharset(Charset charset)
Use this method to set the Charset to be used when calling the getResourceAsReader methods. |
static void |
setDefaultClassLoader(ClassLoader defaultClassLoader)
Sets the default classloader |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static ClassLoader getDefaultClassLoader()
public static void setDefaultClassLoader(ClassLoader defaultClassLoader)
defaultClassLoader - - the new default ClassLoader
public static URL getResourceURL(String resource)
throws IOException
resource - The resource to find
IOException - If the resource cannot be found or read
public static URL getResourceURL(ClassLoader loader,
String resource)
throws IOException
loader - The classloader used to load the resourceresource - The resource to find
IOException - If the resource cannot be found or read
public static InputStream getResourceAsStream(String resource)
throws IOException
resource - The resource to find
IOException - If the resource cannot be found or read
public static InputStream getResourceAsStream(ClassLoader loader,
String resource)
throws IOException
loader - The classloader used to load the resourceresource - The resource to find
IOException - If the resource cannot be found or read
public static Properties getResourceAsProperties(String resource)
throws IOException
resource - The resource to find
IOException - If the resource cannot be found or read
public static Properties getResourceAsProperties(ClassLoader loader,
String resource)
throws IOException
loader - The classloader used to load the resourceresource - The resource to find
IOException - If the resource cannot be found or read
public static Reader getResourceAsReader(String resource)
throws IOException
resource - The resource to find
IOException - If the resource cannot be found or read
public static Reader getResourceAsReader(ClassLoader loader,
String resource)
throws IOException
loader - The classloader used to load the resourceresource - The resource to find
IOException - If the resource cannot be found or read
public static File getResourceAsFile(String resource)
throws IOException
resource - The resource to find
IOException - If the resource cannot be found or read
public static File getResourceAsFile(ClassLoader loader,
String resource)
throws IOException
loader - - the classloader used to load the resourceresource - - the resource to find
IOException - If the resource cannot be found or read
public static InputStream getUrlAsStream(String urlString)
throws IOException
urlString - - the URL to get
IOException - If the resource cannot be found or read
public static Reader getUrlAsReader(String urlString)
throws IOException
urlString - - the URL to get
IOException - If the resource cannot be found or read
public static Properties getUrlAsProperties(String urlString)
throws IOException
urlString - - the URL to get
IOException - If the resource cannot be found or read
public static Class<?> classForName(String className)
throws ClassNotFoundException
className - - the class to load
ClassNotFoundException - If the class cannot be found (duh!)
public static Object instantiate(String className)
throws ClassNotFoundException,
InstantiationException,
IllegalAccessException
className - - the class to create
ClassNotFoundException - If the class cannot be found (duh!)
InstantiationException - If the class cannot be instantiaed
IllegalAccessException - If the class is not public, or other access problems arise
public static Object instantiate(Class<?> clazz)
throws InstantiationException,
IllegalAccessException
clazz - - the class to create
InstantiationException - If the class cannot be instantiaed
IllegalAccessException - If the class is not public, or other access problems arisepublic static Charset getCharset()
public static void setCharset(Charset charset)
charset -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||