Class Resources

java.lang.Object
com.jme3.util.res.Resources

public class Resources extends Object
This class is used to load resources from the default location usually the classpath.
  • Field Details

    • PROPERTY_RESOURCE_LOADER_IMPLEMENTATION

      public static final String PROPERTY_RESOURCE_LOADER_IMPLEMENTATION
      The property name to set the ResourceLoader to use. Should be set automatically by the JmeSystemDelegate. Note: changing this property after the first use of the ResourceLoader will have no effect.
      See Also:
  • Constructor Details

    • Resources

      public Resources()
  • Method Details

    • setResourceLoader

      public static void setResourceLoader(ResourceLoader impl)
      Sets the resource loader implementation to use.
      Parameters:
      impl - The resource loader implementation
    • getResource

      public static URL getResource(String path)
      Finds the resource with the given name.
      Parameters:
      path - The resource name
      Returns:
      The resource URL or null if not found
    • getResource

      public static URL getResource(String path, Class<?> parent)
      Finds the resource with the given name relative to the given parent class or to the root if the parent is null.
      Parameters:
      path - The resource name
      parent - Optional parent class
      Returns:
      The resource URL or null if not found
    • getResourceAsStream

      public static InputStream getResourceAsStream(String path)
      Finds the resource with the given name.
      Parameters:
      path - The resource name
      Returns:
      An input stream to the resource or null if not found
    • getResourceAsStream

      public static InputStream getResourceAsStream(String path, Class<?> parent)
      Finds the resource with the given name relative to the given parent class or to the root if the parent is null.
      Parameters:
      path - The resource name
      parent - Optional parent class
      Returns:
      An input stream to the resource or null if not found
    • getResources

      public static Enumeration<URL> getResources(String path) throws IOException
      Finds all resources with the given name.
      Parameters:
      path - The resource name
      Returns:
      An enumeration of URL objects for the resource. If no resources could be found, the enumeration will be empty.
      Throws:
      IOException - If I/O errors occur
      IOException