Package org.springframework.core.io

# Interface ContextResource

All Superinterfaces:
  `InputStreamSource`, `Resource`

All Known Implementing Classes:
  `DefaultResourceLoader.ClassPathContextResource`

public interface ContextResource extends Resource
Extended interface for a resource that is loaded from an enclosing 'context', for example, from a `jakarta.servlet.ServletContext` but also from plain classpath paths or relative file system paths (specified without an explicit prefix, hence applying relative to the local `ResourceLoader`'s context).

Since:
  2.5
Author:
  Juergen Hoeller
See Also:
  - `org.springframework.web.context.support.ServletContextResource`

## Method Summary

Modifier and Type
Method
Description
`String`
`getPathWithinContext()`
Return the path within the enclosing 'context'.

### Methods inherited from interface org.springframework.core.io.InputStreamSource

`getInputStream`

### Methods inherited from interface org.springframework.core.io.Resource

`contentLength, createRelative, exists, getContentAsByteArray, getContentAsString, getDescription, getFile, getFilename, getURI, getURL, isFile, isOpen, isReadable, lastModified, readableChannel`

## Method Details

### getPathWithinContext

String getPathWithinContext()
Return the path within the enclosing 'context'.

This is typically path relative to a context-specific root directory, for example, a ServletContext root or a PortletContext root.