程序包 com.sh.util.io

类 Resources

java.lang.Object
com.sh.util.io.Resources

public class Resources extends Object

Description: A class to simplify access to resources through the classloader.

Title:首亨软件 - TSS/CRM等

从以下版本开始:
2014年11月11日
  • 方法详细资料

    • getDefaultClassLoader

      public static ClassLoader getDefaultClassLoader()
      Returns the default classloader (may be null).
      返回:
      The default classloader
    • setDefaultClassLoader

      public static void setDefaultClassLoader(ClassLoader defaultClassLoader)
      Sets the default classloader
      参数:
      defaultClassLoader - the new default ClassLoader
    • getResourceURL

      public static URL getResourceURL(String resource) throws IOException
      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

      public static URL getResourceURL(ClassLoader loader, String resource) throws IOException
      Returns the URL of the resource on the classpath
      参数:
      loader - The classloader used to fetch the resource
      resource - The resource to find
      返回:
      The resource
      抛出:
      IOException - If the resource cannot be found or read
    • getResourceAsStream

      public static InputStream getResourceAsStream(String resource) throws IOException
      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 resource
      resource - The resource to find
      返回:
      The resource
      抛出:
      IOException - If the resource cannot be found or read
    • getResourceAsProperties

      public static Properties getResourceAsProperties(String resource) throws IOException
      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 resource
      resource - The resource to find
      返回:
      The resource
      抛出:
      IOException - If the resource cannot be found or read
    • getResourceAsReader

      public static Reader getResourceAsReader(String resource) throws IOException
      抛出:
      IOException
    • getResourceAsReader

      public static Reader getResourceAsReader(String resource, String charset) throws IOException
      Returns a resource on the classpath as a Reader object
      参数:
      resource - The resource to find
      charset - String
      返回:
      The resource
      抛出:
      IOException - If the resource cannot be found or read
    • getResourceAsReader

      public static Reader getResourceAsReader(ClassLoader loader, String resource) throws IOException
      Returns a resource on the classpath as a Reader object
      参数:
      loader - The classloader used to fetch the resource
      resource - The resource to find
      返回:
      The resource
      抛出:
      IOException - If the resource cannot be found or read
    • getResourceAsFile

      public static File getResourceAsFile(String resource) throws IOException
      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

      public static File getResourceAsFile(ClassLoader loader, String resource) throws IOException
      Returns a resource on the classpath as a File object
      参数:
      loader - - the classloader used to fetch the resource
      resource - - the resource to find
      返回:
      The resource
      抛出:
      IOException - If the resource cannot be found or read
    • getUrlAsStream

      public static InputStream getUrlAsStream(String urlString) throws IOException
      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

      public static Reader getUrlAsReader(String urlString) throws IOException
      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

      public static Properties getUrlAsProperties(String urlString) throws IOException
      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

      public static Class<?> classForName(String className) throws ClassNotFoundException
      Loads a class
      参数:
      className - - the class to fetch
      返回:
      The loaded class
      抛出:
      ClassNotFoundException - If the class cannot be found (duh!)