Class Resources2


  • public class Resources2
    extends java.lang.Object

    Since:
    2.0
    Version:
    2.0
    Author:
    Michael Grove
    • Constructor Summary

      Constructors 
      Constructor Description
      Resources2()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.net.URL getResource​(java.lang.Class<?> theClass, java.lang.String theResource)
      Get a resource from the file path specified by the resource name and if that file does not exist, check within the class path, first in the location of the specified class, and then if not found, at the root.
      • Methods inherited from class java.lang.Object

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

      • Resources2

        public Resources2()
    • Method Detail

      • getResource

        public static java.net.URL getResource​(java.lang.Class<?> theClass,
                                               java.lang.String theResource)

        Get a resource from the file path specified by the resource name and if that file does not exist, check within the class path, first in the location of the specified class, and then if not found, at the root. If the resource is not found for any reason, null is returned.

        getResource(MyClass.class, "myprops.properties") will first check for the File "myprops.properties" if that does not exist, then MyClass.getResource("myprops.properties") is checked, and finally if it's still not found, MyClass.getResource("/myprops.properties") will be checked.

        Parameters:
        theResource - the name of the resource to get the location of
        theClass - the class whose classpath the resource might be located in
        Returns:
        the URL to the resource or null if not found