Package jodd.util

Class ResourcesUtil


  • public class ResourcesUtil
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ResourcesUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.io.InputStream getResourceAsStream​(java.lang.String resourceName)
      Opens a resource of the specified name for reading.
      static java.io.InputStream getResourceAsStream​(java.lang.String resourceName, java.lang.ClassLoader callingClass)
      Opens a resource of the specified name for reading.
      static java.io.InputStream getResourceAsStream​(java.lang.String resourceName, java.lang.ClassLoader callingClass, boolean useCache)
      Opens a resource of the specified name for reading.
      static java.lang.String getResourceAsString​(java.lang.String resourceName)  
      static java.net.URL getResourceUrl​(java.lang.String resourceName)
      Retrieves given resource as URL.
      static java.net.URL getResourceUrl​(java.lang.String resourceName, java.lang.ClassLoader classLoader)
      Retrieves given resource as URL.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ResourcesUtil

        public ResourcesUtil()
    • Method Detail

      • getResourceUrl

        public static java.net.URL getResourceUrl​(java.lang.String resourceName,
                                                  java.lang.ClassLoader classLoader)
        Retrieves given resource as URL. Resource is always absolute and may starts with a slash character.

        Resource will be loaded using class loaders in the following order:

        • Thread.currentThread().getContextClassLoader()
        • ClassLoaderUtil.class.getClassLoader()
        • if callingClass is provided: callingClass.getClassLoader()
      • getResourceAsString

        public static java.lang.String getResourceAsString​(java.lang.String resourceName)
                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • getResourceAsStream

        public static java.io.InputStream getResourceAsStream​(java.lang.String resourceName)
                                                       throws java.io.IOException
        Opens a resource of the specified name for reading.
        Throws:
        java.io.IOException
        See Also:
        getResourceAsStream(String, ClassLoader)
      • getResourceAsStream

        public static java.io.InputStream getResourceAsStream​(java.lang.String resourceName,
                                                              java.lang.ClassLoader callingClass)
                                                       throws java.io.IOException
        Opens a resource of the specified name for reading.
        Throws:
        java.io.IOException
        See Also:
        getResourceUrl(String, ClassLoader)
      • getResourceAsStream

        public static java.io.InputStream getResourceAsStream​(java.lang.String resourceName,
                                                              java.lang.ClassLoader callingClass,
                                                              boolean useCache)
                                                       throws java.io.IOException
        Opens a resource of the specified name for reading. Controls caching, that is important when the same jar is reloaded using custom classloader.
        Throws:
        java.io.IOException