类 ResourceUtils


  • public class ResourceUtils
    extends java.lang.Object
    resource util.
    作者:
    boyan
    • 字段概要

      字段 
      修饰符和类型 字段 说明
      private static java.lang.String CLASSPATH_PREFIX  
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      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.io.File getResourceAsFile​(java.net.URL url)
      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, java.lang.String charsetName)
      Returns a resource on the classpath as a Reader object.
      static java.io.InputStreamReader getResourceAsReader​(java.lang.String resource, java.lang.String charsetName)
      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.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • CLASSPATH_PREFIX

        private static final java.lang.String CLASSPATH_PREFIX
        另请参阅:
        常量字段值
    • 构造器详细资料

      • ResourceUtils

        public ResourceUtils()
    • 方法详细资料

      • getResourceUrl

        public static java.net.URL getResourceUrl​(java.lang.String resource)
                                           throws java.io.IOException
        Returns the URL of the resource on the classpath.
        参数:
        resource - The resource to find
        返回:
        The resource
        抛出:
        java.io.IOException - If the resource cannot be found or read
      • getResourceUrl

        public static java.net.URL getResourceUrl​(java.lang.ClassLoader loader,
                                                  java.lang.String resource)
                                           throws java.io.IOException
        Returns the URL of the resource on the classpath.
        参数:
        loader - The classloader used to load the resource
        resource - The resource to find
        返回:
        The resource
        抛出:
        java.io.IOException - If the resource cannot be found or read
      • getResourceAsStream

        public static java.io.InputStream getResourceAsStream​(java.lang.String resource)
                                                       throws java.io.IOException
        Returns a resource on the classpath as a Stream object.
        参数:
        resource - The resource to find
        返回:
        The resource
        抛出:
        java.io.IOException - If the resource cannot be found or read
      • getResourceAsStream

        public static java.io.InputStream getResourceAsStream​(java.lang.ClassLoader loader,
                                                              java.lang.String resource)
                                                       throws java.io.IOException
        Returns a resource on the classpath as a Stream object.
        参数:
        loader - The classloader used to load the resource
        resource - The resource to find
        返回:
        The resource
        抛出:
        java.io.IOException - If the resource cannot be found or read
      • getResourceAsProperties

        public static java.util.Properties getResourceAsProperties​(java.lang.String resource)
                                                            throws java.io.IOException
        Returns a resource on the classpath as a Properties object.
        参数:
        resource - The resource to find
        返回:
        The resource
        抛出:
        java.io.IOException - If the resource cannot be found or read
      • getResourceAsProperties

        public static java.util.Properties getResourceAsProperties​(java.lang.ClassLoader loader,
                                                                   java.lang.String resource)
                                                            throws java.io.IOException
        Returns a resource on the classpath as a Properties object.
        参数:
        loader - The classloader used to load the resource
        resource - The resource to find
        返回:
        The resource
        抛出:
        java.io.IOException - If the resource cannot be found or read
      • getResourceAsReader

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

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

        public static java.io.File getResourceAsFile​(java.lang.String resource)
                                              throws java.io.IOException
        Returns a resource on the classpath as a File object.
        参数:
        resource - The resource to find
        返回:
        The resource
        抛出:
        java.io.IOException - If the resource cannot be found or read
      • getResourceAsFile

        public static java.io.File getResourceAsFile​(java.net.URL url)
        Returns a resource on the classpath as a File object.
        参数:
        url - The resource url to find
        返回:
        The resource
      • getResourceAsFile

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