Class ResourcesUtils


  • public class ResourcesUtils
    extends java.lang.Object
    Resource utils
    • Constructor Summary

      Constructors 
      Constructor Description
      ResourcesUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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.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)
      Returns a resource on the classpath as a Reader object
      static java.io.InputStreamReader getResourceAsReader​(java.lang.String resource)
      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
      • Methods inherited from class java.lang.Object

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

      • ResourcesUtils

        public ResourcesUtils()
    • Method Detail

      • getResourceURL

        public static java.net.URL getResourceURL​(java.lang.String resource)
                                           throws java.io.IOException
        Returns the URL of the resource on the classpath
        Parameters:
        resource - The resource to find
        Returns:
        The resource
        Throws:
        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
        Parameters:
        loader - The classloader used to load the resource
        resource - The resource to find
        Returns:
        The resource
        Throws:
        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
        Parameters:
        resource - The resource to find
        Returns:
        The resource
        Throws:
        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
        Parameters:
        loader - The classloader used to load the resource
        resource - The resource to find
        Returns:
        The resource
        Throws:
        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
        Parameters:
        resource - The resource to find
        Returns:
        The resource
        Throws:
        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
        Parameters:
        loader - The classloader used to load the resource
        resource - The resource to find
        Returns:
        The resource
        Throws:
        java.io.IOException - If the resource cannot be found or read
      • getResourceAsReader

        public static java.io.InputStreamReader getResourceAsReader​(java.lang.String resource)
                                                             throws java.io.IOException
        Returns a resource on the classpath as a Reader object
        Parameters:
        resource - The resource to find
        Returns:
        The resource
        Throws:
        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)
                                                  throws java.io.IOException
        Returns a resource on the classpath as a Reader object
        Parameters:
        loader - The classloader used to load the resource
        resource - The resource to find
        Returns:
        The resource
        Throws:
        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
        Parameters:
        resource - The resource to find
        Returns:
        The resource
        Throws:
        java.io.IOException - If the resource cannot be found or read
      • 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
        Parameters:
        loader - The classloader used to load the resource
        resource - The resource to find
        Returns:
        The resource
        Throws:
        java.io.IOException - If the resource cannot be found or read