Class ResourceUtils


  • public class ResourceUtils
    extends java.lang.Object
    ResourceUtils. Provide a set of convenience methods for working with Resources.
    See Also:
    Resource
    • Constructor Summary

      Constructors 
      Constructor Description
      ResourceUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.io.InputStream getResourceAsStream​(java.lang.Object object, Resource resource)
      Get the InputStream for this resource.
      static java.net.URL getResourceAsURL​(java.lang.Object object, Resource resource)
      Get the URL for this resource.
      • Methods inherited from class java.lang.Object

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

      • ResourceUtils

        public ResourceUtils()
    • Method Detail

      • getResourceAsStream

        public static java.io.InputStream getResourceAsStream​(java.lang.Object object,
                                                              Resource resource)
        Get the InputStream for this resource. Note: to convert an InputStream into an InputReader, use: new InputStreamReader(InputStream).
        Parameters:
        object - The object to grab the Classloader from. This parameter is quite important from a visibility of resources standpoint as the hierarchy of Classloaders plays a role.
        resource - The resource to load.
        Returns:
        If the Resource was found, the InputStream, otherwise null.
        See Also:
        Resource, getResourceAsURL(Object,Resource), InputStream
      • getResourceAsURL

        public static java.net.URL getResourceAsURL​(java.lang.Object object,
                                                    Resource resource)
        Get the URL for this resource.
        Parameters:
        object - The object to grab the Classloader from. This parameter is quite important from a visibility of resources standpoint as the hierarchy of Classloaders plays a role.
        resource - The resource to load.
        Returns:
        If the Resource was found, the URL, otherwise null.
        See Also:
        Resource, getResourceAsStream(Object,Resource)