程序包 com.sh.util.io
类 Resources
java.lang.Object
com.sh.util.io.Resources
Description: A class to simplify access to resources through the classloader.
Title:首亨软件 - TSS/CRM等
- 从以下版本开始:
- 2014年11月11日
-
方法概要
修饰符和类型方法说明static Class<?>classForName(String className) Loads a classstatic ClassLoaderReturns the default classloader (may be null).static FilegetResourceAsFile(ClassLoader loader, String resource) Returns a resource on the classpath as a File objectstatic FilegetResourceAsFile(String resource) Returns a resource on the classpath as a File objectstatic PropertiesgetResourceAsProperties(ClassLoader loader, String resource) Returns a resource on the classpath as a Properties objectstatic PropertiesgetResourceAsProperties(String resource) Returns a resource on the classpath as a Properties objectstatic ReadergetResourceAsReader(ClassLoader loader, String resource) Returns a resource on the classpath as a Reader objectstatic ReadergetResourceAsReader(String resource) static ReadergetResourceAsReader(String resource, String charset) Returns a resource on the classpath as a Reader objectstatic InputStreamgetResourceAsStream(ClassLoader loader, String resource) Returns a resource on the classpath as a Stream objectstatic InputStreamgetResourceAsStream(String resource) Returns a resource on the classpath as a Stream objectstatic URLgetResourceURL(ClassLoader loader, String resource) Returns the URL of the resource on the classpathstatic URLgetResourceURL(String resource) Returns the URL of the resource on the classpathstatic PropertiesgetUrlAsProperties(String urlString) Gets a URL as a Properties objectstatic ReadergetUrlAsReader(String urlString) Gets a URL as a Readerstatic InputStreamgetUrlAsStream(String urlString) Gets a URL as an input streamstatic voidsetDefaultClassLoader(ClassLoader defaultClassLoader) Sets the default classloader
-
方法详细资料
-
getDefaultClassLoader
Returns the default classloader (may be null).- 返回:
- The default classloader
-
setDefaultClassLoader
Sets the default classloader- 参数:
defaultClassLoader- the new default ClassLoader
-
getResourceURL
Returns the URL of the resource on the classpath- 参数:
resource- The resource to find- 返回:
- The resource
- 抛出:
IOException- If the resource cannot be found or read
-
getResourceURL
Returns the URL of the resource on the classpath- 参数:
loader- The classloader used to fetch the resourceresource- The resource to find- 返回:
- The resource
- 抛出:
IOException- If the resource cannot be found or read
-
getResourceAsStream
Returns a resource on the classpath as a Stream object- 参数:
resource- The resource to find- 返回:
- The resource
- 抛出:
IOException- If the resource cannot be found or read
-
getResourceAsStream
public static InputStream getResourceAsStream(ClassLoader loader, String resource) throws IOException Returns a resource on the classpath as a Stream object- 参数:
loader- The classloader used to fetch the resourceresource- The resource to find- 返回:
- The resource
- 抛出:
IOException- If the resource cannot be found or read
-
getResourceAsProperties
Returns a resource on the classpath as a Properties object- 参数:
resource- The resource to find- 返回:
- The resource
- 抛出:
IOException- If the resource cannot be found or read
-
getResourceAsProperties
public static Properties getResourceAsProperties(ClassLoader loader, String resource) throws IOException Returns a resource on the classpath as a Properties object- 参数:
loader- The classloader used to fetch the resourceresource- The resource to find- 返回:
- The resource
- 抛出:
IOException- If the resource cannot be found or read
-
getResourceAsReader
- 抛出:
IOException
-
getResourceAsReader
Returns a resource on the classpath as a Reader object- 参数:
resource- The resource to findcharset- String- 返回:
- The resource
- 抛出:
IOException- If the resource cannot be found or read
-
getResourceAsReader
Returns a resource on the classpath as a Reader object- 参数:
loader- The classloader used to fetch the resourceresource- The resource to find- 返回:
- The resource
- 抛出:
IOException- If the resource cannot be found or read
-
getResourceAsFile
Returns a resource on the classpath as a File object- 参数:
resource- The resource to find- 返回:
- The resource
- 抛出:
IOException- If the resource cannot be found or read
-
getResourceAsFile
Returns a resource on the classpath as a File object- 参数:
loader- - the classloader used to fetch the resourceresource- - the resource to find- 返回:
- The resource
- 抛出:
IOException- If the resource cannot be found or read
-
getUrlAsStream
Gets a URL as an input stream- 参数:
urlString- - the URL to get- 返回:
- An input stream with the data from the URL
- 抛出:
IOException- If the resource cannot be found or read
-
getUrlAsReader
Gets a URL as a Reader- 参数:
urlString- - the URL to get- 返回:
- A Reader with the data from the URL
- 抛出:
IOException- If the resource cannot be found or read
-
getUrlAsProperties
Gets a URL as a Properties object- 参数:
urlString- - the URL to get- 返回:
- A Properties object with the data from the URL
- 抛出:
IOException- If the resource cannot be found or read
-
classForName
Loads a class- 参数:
className- - the class to fetch- 返回:
- The loaded class
- 抛出:
ClassNotFoundException- If the class cannot be found (duh!)
-