public class Resources
extends java.lang.Object
Description: A class to simplify access to resources through the classloader.
Title:首亨软件 - TSS/CRM等
限定符和类型 | 方法和说明 |
---|---|
static java.lang.Class<?> |
classForName(java.lang.String className)
Loads a class
|
static java.lang.ClassLoader |
getDefaultClassLoader()
Returns the default classloader (may be null).
|
static java.io.File |
getResourceAsFile(java.lang.ClassLoader loader,
java.lang.String resource)
Returns a resource on the classpath as a File object
|
static java.io.File |
getResourceAsFile(java.lang.String resource)
Returns a resource on the classpath as a File object
|
static java.util.Properties |
getResourceAsProperties(java.lang.ClassLoader loader,
java.lang.String resource)
Returns a resource on the classpath as a Properties object
|
static java.util.Properties |
getResourceAsProperties(java.lang.String resource)
Returns a resource on the classpath as a Properties object
|
static java.io.Reader |
getResourceAsReader(java.lang.ClassLoader loader,
java.lang.String resource)
Returns a resource on the classpath as a Reader object
|
static java.io.Reader |
getResourceAsReader(java.lang.String resource) |
static java.io.Reader |
getResourceAsReader(java.lang.String resource,
java.lang.String charset)
Returns a resource on the classpath as a Reader object
|
static java.io.InputStream |
getResourceAsStream(java.lang.ClassLoader loader,
java.lang.String resource)
Returns a resource on the classpath as a Stream object
|
static java.io.InputStream |
getResourceAsStream(java.lang.String resource)
Returns a resource on the classpath as a Stream object
|
static java.net.URL |
getResourceURL(java.lang.ClassLoader loader,
java.lang.String resource)
Returns the URL of the resource on the classpath
|
static java.net.URL |
getResourceURL(java.lang.String resource)
Returns the URL of the resource on the classpath
|
static java.util.Properties |
getUrlAsProperties(java.lang.String urlString)
Gets a URL as a Properties object
|
static java.io.Reader |
getUrlAsReader(java.lang.String urlString)
Gets a URL as a Reader
|
static java.io.InputStream |
getUrlAsStream(java.lang.String urlString)
Gets a URL as an input stream
|
static void |
setDefaultClassLoader(java.lang.ClassLoader defaultClassLoader)
Sets the default classloader
|
public static java.lang.ClassLoader getDefaultClassLoader()
public static void setDefaultClassLoader(java.lang.ClassLoader defaultClassLoader)
defaultClassLoader
- the new default ClassLoaderpublic static java.net.URL getResourceURL(java.lang.String resource) throws java.io.IOException
resource
- The resource to findjava.io.IOException
- If the resource cannot be found or readpublic static java.net.URL getResourceURL(java.lang.ClassLoader loader, java.lang.String resource) throws java.io.IOException
loader
- The classloader used to fetch the resourceresource
- The resource to findjava.io.IOException
- If the resource cannot be found or readpublic static java.io.InputStream getResourceAsStream(java.lang.String resource) throws java.io.IOException
resource
- The resource to findjava.io.IOException
- If the resource cannot be found or readpublic static java.io.InputStream getResourceAsStream(java.lang.ClassLoader loader, java.lang.String resource) throws java.io.IOException
loader
- The classloader used to fetch the resourceresource
- The resource to findjava.io.IOException
- If the resource cannot be found or readpublic static java.util.Properties getResourceAsProperties(java.lang.String resource) throws java.io.IOException
resource
- The resource to findjava.io.IOException
- If the resource cannot be found or readpublic static java.util.Properties getResourceAsProperties(java.lang.ClassLoader loader, java.lang.String resource) throws java.io.IOException
loader
- The classloader used to fetch the resourceresource
- The resource to findjava.io.IOException
- If the resource cannot be found or readpublic static java.io.Reader getResourceAsReader(java.lang.String resource) throws java.io.IOException
java.io.IOException
public static java.io.Reader getResourceAsReader(java.lang.String resource, java.lang.String charset) throws java.io.IOException
resource
- The resource to findcharset
- Stringjava.io.IOException
- If the resource cannot be found or readpublic static java.io.Reader getResourceAsReader(java.lang.ClassLoader loader, java.lang.String resource) throws java.io.IOException
loader
- The classloader used to fetch the resourceresource
- The resource to findjava.io.IOException
- If the resource cannot be found or readpublic static java.io.File getResourceAsFile(java.lang.String resource) throws java.io.IOException
resource
- The resource to findjava.io.IOException
- If the resource cannot be found or readpublic static java.io.File getResourceAsFile(java.lang.ClassLoader loader, java.lang.String resource) throws java.io.IOException
loader
- - the classloader used to fetch the resourceresource
- - the resource to findjava.io.IOException
- If the resource cannot be found or readpublic static java.io.InputStream getUrlAsStream(java.lang.String urlString) throws java.io.IOException
urlString
- - the URL to getjava.io.IOException
- If the resource cannot be found or readpublic static java.io.Reader getUrlAsReader(java.lang.String urlString) throws java.io.IOException
urlString
- - the URL to getjava.io.IOException
- If the resource cannot be found or readpublic static java.util.Properties getUrlAsProperties(java.lang.String urlString) throws java.io.IOException
urlString
- - the URL to getjava.io.IOException
- If the resource cannot be found or readpublic static java.lang.Class<?> classForName(java.lang.String className) throws java.lang.ClassNotFoundException
className
- - the class to fetchjava.lang.ClassNotFoundException
- If the class cannot be found (duh!)