org.springframework.core.io

## Class ClassRelativeResourceLoader

- java.lang.Object
- - org.springframework.core.io.DefaultResourceLoader
  - - org.springframework.core.io.ClassRelativeResourceLoader

- All Implemented Interfaces:
    ResourceLoader

      public class ClassRelativeResourceLoader
      extends DefaultResourceLoader

  `ResourceLoader` implementation that interprets plain resource paths as relative to a given `java.lang.Class`.
  Since:
    3.0
  Author:
    Juergen Hoeller
  See Also:
    `Class.getResource(String)`, `ClassPathResource.ClassPathResource(String, Class)`

- - ### Field Summary

    - ### Fields inherited from interface org.springframework.core.io.ResourceLoader

      `CLASSPATH_URL_PREFIX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClassRelativeResourceLoader(Class clazz)` Create a new ClassRelativeResourceLoader for the given class.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Resource` | `getResourceByPath(String path)` Return a Resource handle for the resource at the given path.

    - ### Methods inherited from class org.springframework.core.io.DefaultResourceLoader

      `getClassLoader, getResource, setClassLoader`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ClassRelativeResourceLoader

          public ClassRelativeResourceLoader(Class clazz)

      Create a new ClassRelativeResourceLoader for the given class.
      Parameters:
        `clazz` - the class to load resources through

  - ### Method Detail

    - #### getResourceByPath

          protected Resource getResourceByPath(String path)

      Description copied from class: `DefaultResourceLoader`
      Return a Resource handle for the resource at the given path.

      The default implementation supports class path locations. This should be appropriate for standalone implementations but can be overridden, e.g. for implementations targeted at a Servlet container.

      Overrides:
        `getResourceByPath` in class `DefaultResourceLoader`
      Parameters:
        `path` - the path to the resource
      Returns:
        the corresponding Resource handle
      See Also:
        `ClassPathResource`, `FileSystemXmlApplicationContext.getResourceByPath(java.lang.String)`, `AbstractRefreshableWebApplicationContext.getResourceByPath(java.lang.String)`