Skip to content

Commit c26087e

Browse files
committed
Document PathResource as a built-in Resource in the reference manual
See gh-26447
1 parent 7225238 commit c26087e

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/docs/asciidoc/core/core-resources.adoc

+22-3
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ Other methods let you obtain an actual `URL` or `File` object representing the
150150
resource (if the underlying implementation is compatible and supports that
151151
functionality).
152152

153+
Some implementations of the `Resource` interface also implement the extended
154+
{api-spring-framework}/core/io/WritableResource.html[`WritableResource`] interface
155+
for a resource that supports writing to it.
156+
153157
Spring itself uses the `Resource` abstraction extensively, as an argument type in
154158
many method signatures when a resource is needed. Other methods in some Spring APIs
155159
(such as the constructors to various `ApplicationContext` implementations) take a
@@ -174,11 +178,13 @@ work.
174178
[[resources-implementations]]
175179
== Built-in Resource Implementations
176180

177-
Spring includes the following `Resource` implementations:
181+
Spring includes several built-in `Resource` implementations, including but not limited to
182+
the following:
178183

179184
* <<resources-implementations-urlresource>>
180185
* <<resources-implementations-classpathresource>>
181186
* <<resources-implementations-filesystemresource>>
187+
* <<resources-implementations-pathresource>>
182188
* <<resources-implementations-servletcontextresource>>
183189
* <<resources-implementations-inputstreamresource>>
184190
* <<resources-implementations-bytearrayresource>>
@@ -229,8 +235,21 @@ creates a `ClassPathResource` in that case.
229235
[[resources-implementations-filesystemresource]]
230236
=== `FileSystemResource`
231237

232-
This is a `Resource` implementation for `java.io.File` and `java.nio.file.Path` handles.
233-
It supports resolution as a `File` and as a `URL`.
238+
This is a `Resource` implementation for `java.io.File` handles. It also supports
239+
`java.nio.file.Path` handles, applying Spring's standard String-based path
240+
transformations but performing all operations via the `java.nio.file.Files` API. For pure
241+
`java.nio.path.Path` based support use a `PathResource` instead. `FileSystemResource`
242+
supports resolution as a `File` and as a `URL`.
243+
244+
245+
[[resources-implementations-pathresource]]
246+
=== `PathResource`
247+
248+
This is a `Resource` implementation for `java.nio.file.Path` handles, performing all
249+
operations and transformations via the `Path` API. It supports resolution as a `File` and
250+
as a `URL` and also implements the extended `WritableResource` interface. `PathResource`
251+
is effectively a pure `java.nio.path.Path` based alternative to `FileSystemResource` with
252+
different `createRelative` behavior.
234253

235254

236255

0 commit comments

Comments
 (0)